Forum: JRuby JRuby: gem install paths not working compared to Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
93ecc5fd917944aba00456cbd00a4255?d=identicon&s=25 Johan Wasserman (johanwa)
on 2015-01-05 04:51
HI.  I'm running rvm on Cygwin and find the way the paths are used when
installing gems differ between Ruby and JRuby.  I am unable to install
gems under JRuby.  Any workarounds or fixes would be highly appreciated.

When installing a gem (rails for example) on Ruby (2.2.0) everything
works fine, while trying to install the same gem (rails) on JRuby
(1.7.18 | 1.6.8) I get the error: No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\i18n-0.7.0

I have researched (Googled) this and it seems to be a general problem
that remains unanswered, except for one suggestion to change the
GEM_HOME and GEM_PATH env vars to include the full path, ie:
GEM_HOME="C:/Zones/Programs/xnix/cygwin64/home/Johan
Wasserman/Johan_Wasserman.rvm/gems/jruby-1.7.18"

This works during the install but when I try to run rails (rails
--version) directly after the install I get: bash: rails: command not
found, both with the modified and the original paths for GEM_HOME and
GEM_PATH.

Note that I have implemented the workaround for using spaces in my path
names by adding export rvm_path=/Johan_Wasserman.rvm to .rvmrc, which
works.  I don't feel that the workaround works and the spaces are
irrelevant since the same error occurs in other environments where there
are no spaces in the home paths.

Below is the errors I'm getting with JRuby (please consider that these
errors do not appear with Ruby although the paths look pretty much the
same for both environments), my rvm info for Ruby and JRuby, as well as
my gem env under JRuby:

gem install rails
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\i18n-0.7.0

jruby -S gem install rails
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\i18n-0.7.0

which gem
/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/gem

gem install bundler
Fetching: bundler-1.7.11.gem (100%)
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\bundler-1.7.11

ruby-2.2.0:

  system:
    uname:       "CYGWIN_NT-6.1 HP-PC 1.7.33-2(0.280/5/3) 2014-11-13
15:47 x86_64 Cygwin"
    system:      "cygwin/unknown/x86_64"
    bash:        "/usr/bin/bash => GNU bash, version 4.1.17(9)-release
(x86_64-unknown-cygwin)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.26.8 (latest) by Wayne E. Seguin
<wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com>
[https://rvm.io/]"
    updated:      "3 hours 46 minutes 13 seconds ago"
    path:         "/Johan_Wasserman.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.2.0p0"
    date:         "2014-12-25"
    platform:     "x86_64-cygwin"
    patchlevel:   "2014-12-25 revision 49005"
    full_version: "ruby 2.2.0p0 (2014-12-25 revision 49005)
[x86_64-cygwin]"

  homes:
    gem:          "/Johan_Wasserman.rvm/gems/ruby-2.2.0"
    ruby:         "/Johan_Wasserman.rvm/rubies/ruby-2.2.0"

  binaries:
    ruby:         "/Johan_Wasserman.rvm/rubies/ruby-2.2.0/bin/ruby"
    irb:          "/Johan_Wasserman.rvm/rubies/ruby-2.2.0/bin/irb"
    gem:          "/Johan_Wasserman.rvm/rubies/ruby-2.2.0/bin/gem"
    rake:         "/Johan_Wasserman.rvm/rubies/ruby-2.2.0/bin/rake"

  environment:
    PATH:
"/Johan_Wasserman.rvm/gems/ruby-2.2.0/bin:/Johan_Wasserman.rvm/gems/ruby-2.2.0@global/bin:/Johan_Wasserman.rvm/rubies/ruby-2.2.0/bin:/Johan_Wasserman.rvm/bin:/
am Files (x86)/Java/jre1.8.0_25/bin/client:/cygdrive/c/Program Files
(x86)/Java/jre1.8.0_25/bin:/cygdrive/c/Program Files
(x86)/Java/jre1.8.0_25/lib/i386:/cygdrive/c/ProgramData
Programs/Java/jre1.8.0_20/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/
/c/Users/Johan Wasserman/AppData/Roaming/npm:/cygdrive/c/Program
Files/Boot2Docker for Windows:/cygdrive/c/Zones/Develoment/Aptana Studio
3 Workspace:/usr/lib/lapack"
    GEM_HOME:     "/Johan_Wasserman.rvm/gems/ruby-2.2.0"
    GEM_PATH:
"/Johan_Wasserman.rvm/gems/ruby-2.2.0:/Johan_Wasserman.rvm/gems/ruby-2.2.0@global"
    MY_RUBY_HOME: "/Johan_Wasserman.rvm/rubies/ruby-2.2.0"
    IRBRC:        "/Johan_Wasserman.rvm/rubies/ruby-2.2.0/.irbrc"
    RUBYOPT:      ""
    gemset:       ""



jruby-1.7.18:

  system:
    uname:       "CYGWIN_NT-6.1 HP-PC 1.7.33-2(0.280/5/3) 2014-11-13
15:47 x86_64 Cygwin"
    system:      "cygwin/unknown/x86_64"
    bash:        "/usr/bin/bash => GNU bash, version 4.1.17(9)-release
(x86_64-unknown-cygwin)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.26.8 (latest) by Wayne E. Seguin
<wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com>
[https://rvm.io/]"
    updated:      "2 hours 47 minutes 50 seconds ago"
    path:         "/Johan_Wasserman.rvm"

  ruby:
    interpreter:  "jruby"
    version:      "1.7.18"
"   date:         "jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java
HotSpot(TM) 64-Bit Server VM 1.8.0_25-b18 +jit [Windows 7-amd64]
    platform:     "Windows 7-amd64"
    patchlevel:   "TM"
"   full_version: "jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java
HotSpot(TM) 64-Bit Server VM 1.8.0_25-b18 +jit [Windows 7-amd64]

  homes:
    gem:          "/Johan_Wasserman.rvm/gems/jruby-1.7.18"
    ruby:         "/Johan_Wasserman.rvm/rubies/jruby-1.7.18"

  binaries:
    ruby:         "/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/ruby"
    irb:          "/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/irb"
    gem:          "/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/gem"
    rake:         "/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/rake"

  environment:
    PATH:
"/Johan_Wasserman.rvm/gems/jruby-1.7.18/bin:/Johan_Wasserman.rvm/gems/jruby-1.7.18@global/bin:/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin:/Johan_Wasserman.rvm
/Program Files (x86)/Java/jre1.8.0_25/bin/client:/cygdrive/c/Program
Files (x86)/Java/jre1.8.0_25/bin:/cygdrive/c/Program Files
(x86)/Java/jre1.8.0_25/lib/i386:/cygdrive/c/Progr
Zones/Programs/Java/jre1.8.0_20/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdr
gdrive/c/Users/Johan Wasserman/AppData/Roaming/npm:/cygdrive/c/Program
Files/Boot2Docker for Windows:/cygdrive/c/Zones/Develoment/Aptana Studio
3 Workspace:/usr/lib/lapack"
    GEM_HOME:     "/Johan_Wasserman.rvm/gems/jruby-1.7.18"
    GEM_PATH:
"/Johan_Wasserman.rvm/gems/jruby-1.7.18:/Johan_Wasserman.rvm/gems/jruby-1.7.18@global"
    MY_RUBY_HOME: "/Johan_Wasserman.rvm/rubies/jruby-1.7.18"
    IRBRC:        "/Johan_Wasserman.rvm/rubies/jruby-1.7.18/.irbrc"
    RUBYOPT:      ""
    gemset:       ""


RubyGems Environment:
  - RUBYGEMS VERSION: 2.1.9
  - RUBY VERSION: 1.9.3 (2014-12-22 patchlevel 551) [java]
  - INSTALLATION DIRECTORY: /Johan_Wasserman.rvm/gems/jruby-1.7.18
  - RUBY EXECUTABLE:
C:/Zones/Programs/xnix/cygwin64/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/jruby.exe
  - EXECUTABLE DIRECTORY: /Johan_Wasserman.rvm/gems/jruby-1.7.18/bin
  - SPEC CACHE DIRECTORY: C:/Zones/Programs/xnix/cygwin64/home/Johan
Wasserman/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-java-1.8
  - GEM PATHS:
     - /Johan_Wasserman.rvm/gems/jruby-1.7.18
     -
/Johan_Wasserman.rvm/gems/jruby-1.7.18:/Johan_Wasserman.rvm/gems/jruby-1.7.18@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri --env-shebang"
     - "update" => "--no-rdoc --no-ri --env-shebang"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     -
C:\Zones\Programs\xnix\cygwin64\Johan_Wasserman.rvm\gems\jruby-1.7.18\bin
     -
C:\Zones\Programs\xnix\cygwin64\Johan_Wasserman.rvm\rubies\jruby-1.7.18\lib\ruby\gems\shared\bin
     -
C:\Zones\Programs\xnix\cygwin64\Johan_Wasserman.rvm\rubies\jruby-1.7.18\bin
     - C:\Zones\Programs\xnix\cygwin64\Johan_Wasserman.rvm\bin
     - C:\Zones\Programs\xnix\cygwin64\usr\local\bin
     - C:\Zones\Programs\xnix\cygwin64\bin
     - C:\Program Files (x86)\Java\jre1.8.0_25\bin\client
     - C:\Program Files (x86)\Java\jre1.8.0_25\bin
     - C:\Program Files (x86)\Java\jre1.8.0_25\lib\i386
     - C:\ProgramData\Oracle\Java\javapath
     - C:\Zones\Programs\Java\jre1.8.0_20\bin
     - C:\Windows\system32
     - C:\Windows
     - C:\Windows\System32\Wbem
     - C:\Windows\System32\WindowsPowerShell\v1.0
     - C:\Zones\Programs\nodejs
     - C:\Zones\Programs\xnix\cygwin64\bin
     - C:\Users\Johan Wasserman\AppData\Roaming\npm
     - C:\Program Files\Boot2Docker for Windows
     - C:\Zones\Develoment\Aptana Studio 3 Workspace
     - C:\Zones\Programs\xnix\cygwin64\lib\lapack
2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2015-01-05 06:51
(Received via mailing list)
Remove first standard ruby from your path, or use bundler.

Installing gems always worked using jgem or "jruby -S gem ..."
93ecc5fd917944aba00456cbd00a4255?d=identicon&s=25 Johan Wasserman (johanwa)
on 2015-01-05 22:53
Hi Christian,  thank you for your response, but as you can see from the
snippets above I have no standard ruby in any of the paths. Also, the
second and third error examples show that jruby -S gem does not work,
and that bundler cannot be installed for the same reason, here are these
snippets again:
jruby -S gem install rails
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\i18n-0.7.0

which gem
/Johan_Wasserman.rvm/rubies/jruby-1.7.18/bin/gem

gem install bundler
Fetching: bundler-1.7.11.gem (100%)
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\bundler-1.7.11

What is obvious from these snippets is that jruby's gem installer
converts the directory in to a windows style format, and presumes that
my Cygwin home is located in C:\

Kind regards,
Johan.
2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2015-01-06 00:29
(Received via mailing list)
any further luck using "jruby -s jgem" instead of "jruby -s gem" ?

I use jruby on windows, but without rvm and not on cygwin... I can
guarantee the gem installation works... Any further details you could
share? (OS version, java version, etc...)

On Mon, Jan 5, 2015 at 10:53 PM, Johan Wasserman <lists@ruby-forum.com>
93ecc5fd917944aba00456cbd00a4255?d=identicon&s=25 Johan Wasserman (johanwa)
on 2015-01-06 00:40
Christian,

rvm use jruby
Using /Johan_Wasserman.rvm/gems/jruby-1.7.18

jruby -S jgem install bundler
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory -
C:\Johan_Wasserman.rvm\gems\jruby-1.7.18\gems\bundler-1.7.11


After finding a couple of issues reported on Jira and Github I suspect a
bug in JRuby.

These tests confirm the suspicion:
jruby -S irb
irb(main):001:0> File.exists?('/Johan_Wasserman.rvm/test.txt')
=> true
irb(main):002:0> File.expand_path('/Johan_Wasserman.rvm/test.txt')
=> "C:/Johan_Wasserman.rvm/test.txt"
irb(main):003:0> File.absolute_path('/Johan_Wasserman.rvm/test.txt')
=> "C:/Johan_Wasserman.rvm/test.txt"
irb(main):004:0> File.dirname('/Johan_Wasserman.rvm/test.txt')
=> "/Johan_Wasserman.rvm"


My home path ion Cygwin is /Johan_Wasserman.rvm, translating to the
Windows canonical path
C:\Zones\Programs\xnix\cygwin64\Johan_Wasserman.rvm

expand_path and absolute_path both returned the windows path
C:\Johan_Wasserman.rvm, which of course is incorrect, and therefore the
gem installer cannot find the files it just downloaded.  I'm updating
issue #2387 on Github with my findings.
2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2015-01-06 06:51
(Received via mailing list)
When using jruby, expand path will return paths using java. In your it
is a
standard windows java instalation. You cannot expect a Cygwin path out
of
it...

You need to use a Java setup compatible with Cygwin first.  I do not
know
if this exists.
B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2015-01-06 14:06
(Received via mailing list)
Hi,

I use JRuby in Cygwin without problem. I can get gem installed also. I
did
not use rvm or any other manager. I haven´t installed Rails. If you
want, I
might try to find my configurations for cygwin and Ruby. Some things
I´ve
done:

   - Download jruby.tar from JRuby site
   - untar jruby and copy the directory to my cygwin directory
   - make a symbolic link (ln -s) from ‘jruby’ to ‘jruby-1.7.18/‘ (this
   will make it easier to upgrade later)
   - Download java jdk (from Oracle) and put it on my cygwin directory
   - add symbolic link from ‘jdk-7’ to above directory

In bash_profile

# Add access to java and and jruby before any other path
PATH=/jre7:/jdk-7:/jdk-7/bin:$PATH
PATH=~/bin:/jruby/bin:$PATH

I think this was all. After that, for developing my gems I have created
a
config file to fix cygwin path. Does this help you in any way?

If you need my config.rb file let me know.

Hope this will be of any use!

Cheers…
​

2015-01-06 3:50 GMT-02:00 Christian MICHON <christian.michon@gmail.com>:
93ecc5fd917944aba00456cbd00a4255?d=identicon&s=25 Johan Wasserman (johanwa)
on 2015-01-07 04:41
Hi Rodrigo,
I have to manage my rubies under rvm for now unfortunately. I have
followed your instructions on Java, which makes things a lot easier and
gave me access to javac which I couldn't run before, thanks.

I am curious on what / how you fixed the cygwin path if you are willing
to share your config.rb or snippets of it just so I can get an idea that
would be great.

Christian, I was under the impression that JRuby makes use of Ruby's
File class (http://www.ruby-doc.org/core-1.9.3/File.html), where JRuby
1.7.18 runs of Ruby 1.9.3p551 I believe.

I'm exploring a few options and will have to fall back to running JRuby
outside of rvm as Rodrigo suggests if I want to complete this project.

Thanks,
Johan.
B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2015-01-07 13:53
(Received via mailing list)
Hi Johan,

Sure, the config file is in
https://github.com/rbotafogo/scicom/blob/master/config.rb.  You can use
it
freely if you want.

There are three variables on the top of config:


   - $DVLP: if you are doing development.
   - $ENV: set if your environment is cygwin
   - $DEPEND: array of dependencies if your Gem depends on other Gems
that
   are not installed on your system.  I need this because I develop
MDArray
   and SciCom simultaneously.

If you are in cygwin, then you need to fix the path:

def set_path(path)
`cygpath -a -p -m #{path}`.tr("\n", "")
end

Good luck...

Let me know if this works and if you need any other info!




2015-01-07 1:41 GMT-02:00 Johan Wasserman <lists@ruby-forum.com>:
This topic is locked and can not be replied to.