When I do
bundle install
on my ubuntu server. I get a permission error for all gems that uses native extensions. Like this one.
Installing json 1.8.3 with native extensions
Errno::EACCES: Permission denied # rb_sysopen - /var/www/vhosts/my_application/httpdocs/my_application/gems/gems/json-1.8.3/tests/test_json.rb
I have installed ruby 2.2.1 with rvm and I have a local gemset for this user.
I am guessing that it might be a problem regarding the users permissions, but I don't know how to fix it.
There could also be something I need to install. Like ruby-dev?
Here are some info from the server.
rvm list
rvm rubies
=* ruby-2.2.1 [ x86_64 ]
ruby-2.2.1-dev [ x86_64 ]
ruby-2.2.4 [ x86_64 ]
# => - current
# =* - current && default
# * - default
ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
bundler --version
Bundler version 1.11.2
Thanks!
Related
I apologize if I've missed something obvious. I am new to Ruby.
My overall goal is to add functionality to an existing script, which is using rvm and gemsets.
When I install new gems to a particular gemset, the requires in my scripts fail to find them. I am using the following rvm instance:
$ rvm current
jruby-1.6.7.2#preflight
To confirm:
$ which ruby
/Users/user/.rvm/rubies/jruby-1.6.7.2/bin/ruby
$ ruby -v
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.8.0_11) [darwin-x86_64-java]
I specified the gemset into I install a given gem (let's say xml-simple).
$ rvm #preflight do gem install xml-simple
Successfully installed xml-simple-1.1.5
1 gem installed
To verify the gem installed correctly:
$ gem list
*** LOCAL GEMS ***
...
xml-simple (1.1.5)
...
We see the module I installed there.
Following the xml-simple instructions to include the module, I run this script:
require 'xmlsimple'
which, results in:
$ ruby testver.rb
LoadError: no such file to load -- xmlsimple
require at org/jruby/RubyKernel.java:1033
(root) at testver.rb:1
One suspicious thing I have seen is that printing out RUBY_VERSION and $LOAD_PATH shows me this:
$ ruby testver.rb
1.8.7
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/1.8
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/shared
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.8
.
Adding require "rubygems" is required prior to Ruby version 1.9.2, per this stackoverflow answer. This resolved my issue.
I'm new with ruby and I'm facing a problem with installing some gems required by a ruby project I'm trying to build
I have installed rvm and I try to run the following command to fetch, if I understand well the missing dependencies of my project
$> jruby --1.9 /home/user/.gem/jruby/1.9/bin/bundle install
And I fall into the following exception:
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 0.9.6
Installing addressable 2.3.6
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/jruby-1.7.12-dev/bin/jruby extconf.rb
/usr/local/rvm/rubies/jruby-1.7.12/lib/ruby/shared/mkmf.rb:14: Use RbConfig instead of obsolete and deprecated Config.
mkmf.rb can't find header files for ruby at /usr/local/rvm/rubies/jruby-1.7.12/lib/native/include/ruby/ruby.h
extconf failed, uncaught signal 1
Gem files will remain installed in /usr/local/rvm/gems/jruby-1.7.12/gems/cool.io-1.2.4 for inspection.
Results logged to /usr/local/rvm/gems/jruby-1.7.12/extensions/universal-java-1.7/1.9/cool.io-1.2.4/gem_make.out
My version is
$> ruby -v
jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_60-b19 [linux-amd64]
I've seen on similar posts that a dev package is missing but how do I install it via rvm?
JRuby's native extension support was an experiment and is not recommended to be used.
All of your gems that use MRI's native extension API might just no longer work on JRuby, usually mature gems provide a JRuby specific alternative but that is not always the case.
cool.io gem seems to be one of those (will only work on MRI as it needs to build it's native extension)
I have no idea why but RVM can't seem to change the default Ruby. I'm using Oh My Zsh and tried everything I've found but nothing seems to work.
➜ Sites rvm use 2.0.0 --default
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites rvm list
rvm rubies
=* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
➜ Sites rvm reload && rvm list
RVM reloaded!
rvm rubies
* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Now the Ruby is set as default but RVM doesn't load it as "current", which means it does not load the gemsets that are affiliated to it.
➜ Sites rvm use 2.0.0
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites gem list
*** LOCAL GEMS ***
backports (3.3.3)
bson (1.9.1)
bson_ext (1.9.1)
bundler (1.3.5)
bundler-unload (1.0.1)
eventmachine (1.0.3)
genghisapp (2.3.7)
json (1.8.0)
mongo (1.9.0)
mustache (0.99.4)
rack (1.5.2)
rack-protection (1.5.0)
rack-test (0.6.2)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sass (3.2.10)
sass-globbing (1.1.0)
sinatra (1.4.3)
sinatra-contrib (1.4.0)
sinatra-mustache (0.1.0)
tilt (1.4.1)
vegas (0.1.11)
➜ Sites rvm reload && gem list
RVM reloaded!
*** LOCAL GEMS ***
Nothing.
I have no .bashrc nor .bash_profile. There is no RVM reference in my .zprofile and here is my .zshrc :
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="robbyrussell"
DEFAULT_USER="anahkiasen"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git bower brew composer gem laravel sublime)
## RVM and Rubygems
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
source $ZSH/oh-my-zsh.sh
I've tried swapping the above two lines, tried moving the RVM loading into .zprofile, nothing. Everytime I open a new instance of the terminal, the default is gone.
It loads the correct ruby, meaning if I do ruby -v I get the version I want, but for RVM it's not loaded and thus I have none of the gemsets.
I've also tried rvm --default use 2.0.0, rvm use 2.0.0#develop --default but same result.
I've reinstalled RVM, I've set recursively the permissions of the .rvm folder to the current user, nothing.
I'm kind of desperate at that point.
As you are using OH-MY-ZSH you might be hitting issue similar to this: https://github.com/robbyrussell/oh-my-zsh/pull/1359
RVM has a "fix" function, run:
rvm get head --auto-dotfiles
It will reorganize your dot files - it is important to read the output and follow instructions.
Make sure to use login shell for best effect.
Ah ha !! I just faced the same problem and resolved it eventually.
Let me reiterate my issue: Everytime i start my terminal, i had to first do a bundle install each time. Then i figured, Its not correct. So i tried sourcing my zshrc.
So everytime i had to do source ~/.zshrc or simply zsh also did the same and my gemset would get identified. Ofcourse assuming RVM and all other dependencies are installed correctly
Finally i figured i needed to do the following:
$ vim ~/.zlogin
The contents of the .zlogin should be
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
zsh #to initiate zsh (you could also replace this with 'source ~/.zshrc')
This resolved my problem. Now everytime i start my terminal, my defaults are all set.
Let me know if this works for you.
I installed RVM as per the instructions on http://rvm.io. Here's what I've done: rvm list:
rvm rubies
=* ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Followed by a ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
And then a rvm docs generate:
Currently 'rvm docs ...' does not work with non-rvm rubies.
I then tried rvm reinstall 1.9.3 && rvm docs generate. This resulted in the rvm giving me the above error.
How do I generate docs with rvm?
you need to use ruby first:
rvm use 1.9.3
I am using the rvm binary (i.e. I did not build it from sources). See this git issue for more details. Doing a rvm reinstall 1.9.3 --disable-binary will build rvm from source and allow you to generate docs with rvm. (At least for version 1.9.3)
I'm trying to get Rails 3 up and running by following the steps outlined in "Ruby on Rails Tutorial" by Michael Hartl (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book).
The details start in section 1.2.2 (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:rubygems). Here you go through the following steps:
Installing Git
Installing Ruby (version 1.9.2) using Ruby Version Manager (RVM)
Creating different gemsets for environments using Ruby 1.8.7 and 1.9.2
Installing RubyGems
and finally, installing Rails.
I run the following command [sudo] gem install rails --version 3.0.7
Everything seemed to install correctly (based on no errors). However, when I type "rails -v", rails cannot be found.
I am a Rails newbie. I'm trying to install Rails on a machine running Mac OS X 10.6.7.
Thanks.
If you are using RVM you probably don't want to use sudo when installing gems. If you have Git installed only steps needed to get Rails are:
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.zshrc
# Reload your shell now (open a new terminal for example)
rvm install 1.9.2
rvm 1.9.2 --default
gem install rails --version 3.0.7
hash -r
This skips the gemsets part (you don't need it if you are just starting learning Rails) and assumes that you use Zsh (I think it's Mac OS X default, if you use Bash then you have to alter .bashrc, not .zshrc).
If you want to remove your previous installation and start over use rvm implode.