c - How can I link my JSON extension to the correct Ruby version? -
if install ruby 2.1.6 (or 2.2.2, etc) , try require 'json', segfault. reported this , told "your json extension linked ruby 2.0.0, not ruby 2.1.6."
i install ruby versions ruby-install, , don't understand details of compiling ruby.
how can extension link right version of ruby?
clarification
this question compiling c source of ruby executable. requires c knowledge answer, not ruby knowledge; that's why tagged both languages.
my real goal able rails server latest ruby version (currently 2.2.2). doing require 'json' triggers segfault, rails s does.
update
i'm looking walk me through figuring out , fixing this.
i've tried moving entire ~/.rubies folder ~/.old_rubies , doing ruby-install ruby 2.2.2 scratch. i've tried uninstalling every json gem let me (although won't let me remove default gem). irb; require 'json' works, starting rails server segfaults.
it sounds you're dealing classic dependency-hell problem.
first things first: need isolate environment. don't want os-installed ruby or gems interfering project-installed ruby.
install these tools:
- install
ruby-install: https://github.com/postmodern/ruby-install - install
chruby: https://github.com/postmodern/chruby - install
gem_home: https://github.com/postmodern/gem_home
and follow homebrew directions each.
now install preferred ruby:
ruby-install ruby 2.2.2 navigate project directory:
cd ~/projects/operation-snugglepants switch preferred ruby:
chruby 2.2.2 then ensure you're not being pre-empted system ruby:
which ruby should give path like
~/.rubies/ruby-2.2.2/bin/ruby and verify it's right version:
ruby -v ruby 2.2.2p95 ... great -- you've got right ruby. let's make sure have right gems. set gem installation target project's directory:
gem_home . and install bundler:
gem install bundler then install gems:
bundle install after that's done, bundle rails server , verify it's working:
bundle exec rails server => booting webrick => rails 4.2.0 application starting in development on http://localhost:3000 always make sure you've isolated system dependencies (system ruby , system gems) application dependencies (application ruby , application gems). never mix 2 if @ possible.
i use short bash script loads aliases on shell's startup "jump" ruby-project-specific environments, make things easier work -- feel free swipe it!
Comments
Post a Comment