我正在尝试从.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无法找到库,因为它正在寻...

我正在尝试从.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”的潜在用法但听起来很脏,除非有很好的方法.
解决方法:
您是否正在使用混合本机Windows ruby??gems和Cygwin ruby???使用Cygwin ruby??gems似乎对我来说很好. (为什么你的Cygwin ruby??解释器显然在搜索带有Windows反斜杠的路径?).
或者,你试过run.exe吗?
C:\cygwin\bin\run.exe -p /starting/dir exe_to_run
这是man-page条目:
NAME
run – start programs with hidden console window
SYNOPSIS
run [ -p path ] command [ -wait ] arguments
runcommand [ -p path ] [ -wait ] arguments
DESCRIPTION
Windows programs are either GUI programs or console programs. When
started console programs will either attach to an existing console
or create a new one. GUI programs can never attach to an exiting con-
sole. There is no way to attach to an existing console but hide it if
started as GUI program.run will do this for you. It works as intermediate and starts a pro-
gram but makes the console window hidden.With -p path you can add path to the PATH environment variable.
Issuing -wait as first program argument will make run wait for program
completition, otherwise it returns immediately.The second variant is for creating wrappers. If the executable is
named runcommand (eg runemacs), run will try to start the program (eg
emacs).EXAMPLES
run -p /usr/X11R6/bin xterm
run emacs -wait
runemacs -waitrun make -wait
本文标题为:c# – 从.NET执行Cygwin进程?


基础教程推荐
- Unity shader实现高斯模糊效果 2023-01-16
- c# – USING块在网站与Windows窗体中的行为不同 2023-09-20
- C#调用摄像头实现拍照功能的示例代码 2023-03-09
- C#中 Json 序列化去掉null值的方法 2022-11-18
- C#通过标签软件Bartender的ZPL命令打印条码 2023-05-16
- Unity 如何获取鼠标停留位置下的物体 2023-04-10
- C# 解析XML和反序列化的示例 2023-04-14
- C#获取指定目录下某种格式文件集并备份到指定文件夹 2023-05-30
- C#中的Linq to JSON操作详解 2023-06-08
- 实例详解C#实现http不同方法的请求 2022-12-26