ruby -v give me ruby-1.9.3-p194.
which ruby gives /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
rails -v gives Rails 3.2.7
which rails gives /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/bin/rails
"sudo bundle exec rails s" gives:
ubuntu#ip-10-117-73-5:~/ruby/users$ sudo bundle exec rails s
=> Booting WEBrick
=> Rails 3.2.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-09-11 20:13:08] INFO WEBrick 1.3.1
[2012-09-11 20:13:08] INFO ruby 1.8.7 (2011-06-30) [i686-linux]
[2012-09-11 20:13:08] INFO WEBrick::HTTPServer#start: pid=4240 port=3000
rvn info gives me:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i686-linux]
- INSTALLATION DIRECTORY: /home/ubuntu/.rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/ubuntu/.rvm/gems/ruby-1.9.3-p194
- /home/ubuntu/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
However when I run rails server I see below.
[2012-09-11 18:19:53] INFO ruby 1.8.7 (2011-06-30) [i686-linux]
I have no clue where this is coming from.
I have done "bundle install" and "bundle update" and a whole slew of things - it still is using the wrong ruby version. What do I need to do?
EDIT:
$PATH variable also only shows me 1.9.3 relevant information, how the heck is Webrick getting 1.8.7! If I remove that folder - it just doesn't start at all
Well seems what i needed was
rvmsudo rails server
I am just now learning when to use sudo and when not to - this was a painful experience.
Problem was that 1.8.7 was installed for sudo - while everything else was right for my user. But since I couldn't run 'rails server' by itself due to my previous incorrect installation, i had to use 'sudo rails server' - which ended up using the older ruby version.
Related
I'm trying to run a single unit test in my Rails app, I'm using the following command to run the test (say my model is users)
rake test TEST=test/unit/user_test.rb
It runs with out a problem, but for some reason it runs three times; can anyone explain me why is that and if I'm doing something wrong above? Following is my gem env, and I'm using Rails 2.3.2.
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357
- RUBY EXECUTABLE: /home/sameera/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
- EXECUTABLE DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/sameera/.rvm/gems/ruby-1.8.7-p357
- /home/sameera/.rvm/gems/ruby-1.8.7-p357#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
In a rails app rake test runs 3 subtasks, test:units, test:functionals, test:integration.
Each of those tasks just runs all the tests from the corresponding folder, but your environment variable overrides that search process and so the same file is found each time.
You could either do
rake test:units TEST=...
or
ruby -I test test/unit/user_test.rb
If I startup my WEBrick server using
bundle exec jruby -S rails s
I'm getting following warning
c:/Program Files/jruby-1.6.7/lib/ruby/gems/1.8/gems/activesupport-
3.2.2.rc1/lib/active_support/core_ext/string/output_safety.rb:34
warning: regexp match /.../n against to UTF-8 string
Now, don't mind the warning, that's not part of my question. What is part of the question is why gems from 1.8 are being used when JRuby is set to used 1.9 mode?
$ bundle exec jruby -S rails s
=> Booting WEBrick
=> Rails 3.2.2.rc1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-05 13:41:02] INFO WEBrick 1.3.1
[2012-03-05 13:41:02] INFO ruby 1.9.2 (2012-02-22) [java]
[2012-03-05 13:41:02] INFO WEBrick::HTTPServer#start: pid=7624 port=3000
Version:
$ jruby -v
jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8)
(Java HotSpot(TM) Client VM 1.6.0_27) [Windows Vista-x86-java]
This got me curious too! (=
Irrespective of the mode you are using, the master repo for gem is in the
1.8 directory:
$ jruby -S gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.9
- RUBY VERSION: 1.8.7 (2011-10-25 patchlevel 330) [java]
- INSTALLATION DIRECTORY: C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
...
- GEM PATHS:
- C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
- C:/.gem/jruby/1.8
And with --1.9:
$ jruby --1.9 -S gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.9
- RUBY VERSION: 1.9.2 (2011-10-25 patchlevel 136) [java]
- INSTALLATION DIRECTORY: C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
...
- GEM PATHS:
- C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
- C:/.gem/jruby/1.9
The installation directory is set at JRuby compile time by the jruby.gem.home which is set by default to:
jruby.gem.home.1.8=lib/ruby/gems/1.8
(in default.build.properties in the JRuby codebase)
However, this shouldn't be a problem because when running in --1.9 mode, the LOAD_PATH contains 1.8.
$ jruby --1.9 -rpp -e 'pp $LOAD_PATH'
["C:/dev/jruby-1.6.5/lib/ruby/site_ruby/1.9",
"C:/dev/jruby-1.6.5/lib/ruby/site_ruby/shared",
"C:/dev/jruby-1.6.5/lib/ruby/site_ruby/1.8",
"C:/dev/jruby-1.6.5/lib/ruby/1.9"]
Using heroku for deployment while learning Rails with the Ruby On Rails tutorial by Michael Hartl, on Ubuntu 11.04 Natty Narwhal. I installed it using
sudo gem install heroku
and the commands seemed to run fine for that session in the terminal. The next time I went to work, I tried the command "heroku open" and I was told "heroku: command not found". Looking at some of the answers to similar problems here, it seemed the answer was to run
gem enviroment
which returned the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/richard/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I then ran
$ export PATH=$PATH:/var/lib/gems/1.8/bin
which seemed to fix the problem. However, the next time I tried to run heroku in the terminal, I was told "command not found" again! Running the "export PATH=$PATH" command seems to fix the problem every time, but I would rather I didn't have to run this command everytime I want to use heroku. Is there any permanent solution to the problem?
If you're using bash as your shell, then add that export line to .bash_profile in your home directory. The equivalent for zsh is .zshrc, and other shells have their own files to automatically load for every shell session.
I'm currently trying to get Thin webserver running on Windows, to form a basic cluster behind a NGINX proxy, but this is proving to be rather difficult.
I was wondering if anyone actually succeeded in getting this up and running?
To give some examples of the things I have tried:
C:\Users\arne.de.herdt.TENFORCE2\RubymineProjects\ESCO>thin start
C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:926:in `report_activate_error': Rub
yGem version error: thin(1.2.11 not >= 0) (Gem::LoadError)
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:244:in `activate_dep'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:236:in `activate'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:1307:in `gem'
from C:/Ruby/bin/thin:18:in `<main>'
I really don't get this error message. I've included below the environmental output of my system that I'm trying this on (my development system)
RubyGems Environment:
- RUBYGEMS VERSION: 1.7.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby/lib/ruby/gems/1.9.1
- C:/Users/arne.de.herdt.TENFORCE2/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Hoping someone has been experimenting with this.
Also I must say that it's starting to annoy me that the lack for Windows support is such a serious issue with Ruby on Rails. I really enjoy the language and programming in it, but it's a pain getting things to work on Windows machines because of uncompilable dependencies...
Thin ain't supported under Windows.....
Everytime I start my Rails applications I get LoadError with the following output.
On Rails 2.3.8:
no such file to load -- sqlite3/sqlite3_native
<internal:lib/rubygems/custom_require>:29:in `require'
On Rails 3.0.0:
no such file to load -- bundler
<internal:lib/rubygems/custom_require>:29:in `require'
I run the applications in the production mode on a development machine using Nginx + Passenger.
What is the reason of this issue? How can I solve it?
Thanks.
Debian GNU/Linux 5.0.6;
Ruby 1.9.2;
Rubygems 1.3.7;
Ruby on Rails 2.3.8, 3.0.0;
Nginx 0.8.50;
Passenger 2.2.15;
sqlite3-ruby 1.3.1;
bundler 1.0.0.rc.6.
Updated
All of my gems is installed by the unprivileged user in the local directory /home/<usernam>/.gem. If it helps, here's the gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /home/<username>/.gem
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/<username>/.gem/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/<username>/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :gemhome => "/home/<username>/.gem"
- :gempath => ["/home/<username>/.gem"]
- REMOTE SOURCES:
- http://rubygems.org/
Updated
I tackled with the problem. Its source was that I defined a custom gem path. That is I added to the ~/.gemrc file the following lines:
:gemhome: /home/<username>/.gem
:gempaths:
- /home/<username>/.gem
Thus all of my gems was placed in the specified directory but not the default one. For some reason Rubygems coundn't find it there and rose an exception.
When I removed that lines from the file the default paths was set for Rubygems and after I installed all the required gems and loaded my Rails applications all began to work.
Once again, the bug conditions are:
Nginx + Passenger;
The gempath is set to /home/<unprivileged_user>/.gem in ~/.gemrc;
An init.d script is creaded and added to the boot sequence (update-rc.d nginx defaults);
System is rebooted, server is started atomaticlally;
http://localhost/my_rails_app;
LoadError; no such file to load -- <gem_name>; <internal:lib/rubygems/custom_require>:29:in `require'.
Why can't Rubygems find gems in the custom location but can find them in default? That's the question.
I too had this problem when using RVM - I must have specified a gemset or something and not made it project specific. At any rate, read this rvm guide if you want to know the basics of RVM and try to specify a new gemset for your current folder / project, install a new rails gem to that gemset, and then use that gemset. For example, to create a new gemset for rails version 2.3.8:
$ rvm gemset create rails238
$ rvm ruby-1.8.7#rails238
$ gem install rails -v 2.3.8
Then if all went according to plan type rvm gemset use [gemsetName], or do rvm gemset list to see a list of installed gemsets, and to see if rails is working fine try rails -v and you should see rails 2.3.8
Check your system to locate where your rubies and gems are installed ( you can do this by "which ruby" and "which gem"). Usually, they're installed in the same folder (/usr/bin or /usr/local). If they are in different locations, there might be load error. Just a suggestion.