从 .NET 执行 Cygwin 进程?
我正在尝试从 .NET 应用程序启动 Cygwin 版本的 ruby.exe,但我陷入困境。
c:\>"c:\cygwin\bin\ruby.exe" c:\test\ruby.rb
/usr/bin/ruby: no such file to load -- ubygems (LoadError)
正如您所看到的,Ruby 无法找到库,因为它正在寻找一些 Linux 风格的路径。
显然,当我从 .NET 运行 ruby.exe 时,因为它找不到库,所以会像上面一样失败。
如果我不加载任何库,它工作正常:
c:\>"c:\cygwin\bin\ruby.exe" -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
最初 cygwin 以 cygwin.bat 开头
chdir C:\cygwin\bin
bash --login -i
我怎样才能使.NET 首先进入 cygwin 环境,然后在该环境中执行 ruby?
- 我无法使用 Windows Ruby,我需要 cygwin ruby。
- 我知道交互驱动“bash”的潜在用途,但这听起来很脏,除非有很好的方法。
I'm trying to launch Cygwin version of ruby.exe from a .NET application, but I'm stuck.
c:\>"c:\cygwin\bin\ruby.exe" c:\test\ruby.rb
/usr/bin/ruby: no such file to load -- ubygems (LoadError)
As you see Ruby can't locate libraries because it's looking some Linux style paths.
Obviously when I run ruby.exe from .NET since it can't find libraries it fails like above.
If I don't load any library it works fine :
c:\>"c:\cygwin\bin\ruby.exe" -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Originally cygwin starts with this cygwin.bat
chdir C:\cygwin\bin
bash --login -i
How can I make .NET to first go into cygwin enviroment and then execute ruby in that enviroment ?
- I can't use Windows Ruby, I need to cygwin ruby.
- I'm aware of potential usage of interactively driving "bash" but that sounds dirty, unless there is nice way of doing it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在混合使用本机 Windows rubygems 和 Cygwin ruby? 使用 Cygwin rubygems 似乎对我来说效果很好。 (为什么你的 Cygwin ruby 解释器显然在搜索包含 Windows 反斜杠的路径?)。
或者,您是否尝试过
run.exe
?这是手册页条目:
Are you using perhaps mixing native Windows rubygems and Cygwin ruby? Using Cygwin rubygems seems to work fine for me. (Why is your Cygwin ruby interpreter apparently searching a path with Windows backslashes in it?).
Alternatively, have you tried
run.exe
?Here's the man-page entry:
为什么不执行一个从 .NET 应用程序运行 ruby 的非交互式 bash shell? 例如:
不确定您的文件结构,但例如,
查看 bash 中的 -c 选项手册页以获取更多信息。
Why don't you execute a non-interactive bash shell which runs ruby from your .NET application? Something like:
Not sure your file structure, but for example,
Look at the -c option from the bash man page for more info.