Rubygems + Cygwin: Posix Path Not Found by Ruby.Exe

RubyGems + Cygwin: POSIX path not found by ruby.exe

You're trying to mix batch files which expect native paths with Cygwin, which completely dislike it.

When you call ./gem you're invoking the ruby script, but using the PATH is invoking the batch file.

Either you tell cygwin not to process batch files (dunno how) or you use MSYS Bash if you want a replacement of cmd.exe, but don't mix Cygwin with native Ruby.

I've blogged about mixing and matching in the past:

http://blog.mmediasys.com/2008/10/27/handy-tip-dont-mix-one-click-installer-with-cygwin/

Is there a way to make rubyinstaller play nice with cygwin?

The problem is cygwin converting all the scripts paths into cygwin paths (/cygdrive/...).

There is no solution for that since the invoke of the script is made from bash over rake scrip which invokes native Ruby.

There are a lot of other issues that cygwin will cause, and some are covered in RubyInstaller troubleshooting page

One alternative will be invoking rake.bat directly, skipping cygwin shebang detection.

But cygwin doesn't like batch files, which forces you to do cmd.exe /C rake.bat and that is a noisy command line.

The other alternative is install something like gem-exefy (gem install gem-exefy) and generate executables for your installed gems (rake.exe).

That way you invoke rake.exe instead of letting cygwin figure it out.

Another alternative is use MSYS Bash (included in DevKit) instead of cygwin, which plays way better than cygwin one, but you will still have issues with batch files.

As you can see, mixing non-native (cygwin) with native (RubyInstaller) have a lot of side-effects.

Is there a way to make rubyinstaller play nice with cygwin?

The problem is cygwin converting all the scripts paths into cygwin paths (/cygdrive/...).

There is no solution for that since the invoke of the script is made from bash over rake scrip which invokes native Ruby.

There are a lot of other issues that cygwin will cause, and some are covered in RubyInstaller troubleshooting page

One alternative will be invoking rake.bat directly, skipping cygwin shebang detection.

But cygwin doesn't like batch files, which forces you to do cmd.exe /C rake.bat and that is a noisy command line.

The other alternative is install something like gem-exefy (gem install gem-exefy) and generate executables for your installed gems (rake.exe).

That way you invoke rake.exe instead of letting cygwin figure it out.

Another alternative is use MSYS Bash (included in DevKit) instead of cygwin, which plays way better than cygwin one, but you will still have issues with batch files.

As you can see, mixing non-native (cygwin) with native (RubyInstaller) have a lot of side-effects.

There was an error while trying to write to C:/Users/REMOTE~1/AppData/ on Bundle Install [Rails 5.1.3, Ruby 2.3.3]

After 3 days of tinkering and trying to find a solution I came up with the following.

1.) As @anothermh mentioned, it is probably best to install Ruby on Windows Subsystem for Linux Installing Ruby on WSL (Windows Subsystem for Linux) to avoid these kind of situations.

2.) For people who still want to continue using Ruby on their windows systems.

This error occurs when your bundler rubygems copy is corrupted and gets cached into your system.

I solved this by deleted the folder .bundle in C:/users/my_user/.bundle

Re-install bundler and this error goes away and your gems compile and install as usual.

failed to build native extension for bcrypt-ruby gem under cygwin on windows xp

I have dodged it the following way:
Install Rubyinstaller for my version of Ruby:

http://rubyinstaller.org/

Remove Cygwin from my Path (Right Click My Computer > Properties > Advanced > Environment Variables).

Downloaded Git Bash and set up ssh by following the instructions here:

http://mrsimonelliott.com/blog/setting-git-and-github-windows-xp

Downloaded Ruby Installer DevKit

http://rubyinstaller.org/add-ons/devkit/

Downloaded QT

http://qt-project.org/downloads
(The mingw directory is within where I installed Git)

Added QT/bin to the Path.

I only get on version of Ruby but I suppose that when this becomes an issue, I can always use Pik.

I am fairly convinced this is an RVM issue by the way.

which in ruby: Checking if program exists in $PATH from ruby

True cross-platform solution, works properly on Windows:

# Cross-platform way of finding an executable in the $PATH.
#
# which('ruby') #=> /usr/bin/ruby
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
end
end
nil
end

This doesn't use host OS sniffing, and respects $PATHEXT which lists valid file extensions for executables on Windows.

Shelling out to which works on many systems but not all.



Related Topics



Leave a reply



Submit