0

All the time when I do a git clone https://github.com/[REPO_NAME] and then cd into the repo and run bundle install I get

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/name/.rvm/rubies/ruby-2.1.3/bin/ruby extconf.rb 

* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

And most of the time this has to do with an error occurring while installing eventmachine

Otherwise, all of the rails app created by me can be ran locally with no issues it just do not work when I am trying to run locally git cloned app.

I am just confused, I tried to change my ruby version, updated xcode and reset the gemfile.lock I just do not know whats wrong with my local environment.

Please I need some light as in what should I look into ? What should I check to make gem dependencies work when I am trying to run an app locally which is not created by me but that is a git cloned app?

Thanks a lot in advance to all the kind contributors.

UPDATE:

rvm -v:

rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

rvm list:

rvm rubies

   ruby-2.1.2 [ x86_64 ]
=* ruby-2.1.3 [ x86_64 ]
   ruby-2.1.5 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

which ruby:

/Users/name/.rvm/rubies/ruby-2.1.3/bin/ruby

brew -v:

Homebrew 0.9.5

brew doctor:

otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
Antoine
  • 559
  • 8
  • 21
  • r u switching to appropriate ruby version and rails version every time you clone a new repo in your local? and then running bundle install. – Hare Kumar Mar 26 '15 at 19:35
  • well the repo do not have any ruby version mentioned but I thought that by running bundle install it would set up the appropriate rails version. I know how to switch from one ruby -v to another but how so you switch rails version ? – Antoine Mar 26 '15 at 20:06
  • the best way would be 'create a gemset for specific ruby version and rails version'. – Hare Kumar Mar 26 '15 at 20:12
  • For rails version check your gemfile from repo. It would be there. – Hare Kumar Mar 26 '15 at 20:13

2 Answers2

1

I am not sure if this answer your question exactly. But it will help you for sure. So, please give it a try and check if the issue still exists.

Step 1: rvm use ruby-version # switch to specific ruby 
Step 2: rvm gemset create r4.2 # Create new gemset. Give name based on rails version. It will help you keep track of ruby and rails version together. 

Then you can switch to specific ruby gemset using rvm use command.

Step 3: rvm use ruby-version@r4.2

Now do bundle install. And you will have separate wrappers for your project.

Now add two new file .ruby-version and .ruby-gemset in your project repo to avoid typing rvm use every time you cd in directory.

Content of `.ruby-version`:   
ruby-2.2.0 # ruby version respective to your project

Content of `.ruby-gemset`:  
r4.2 # gemset name 

So, Now whenever you cd to your project directory. It will automatically switch to respective ruby version and rails version. Hence this way you can avoid conflict. And do bundle install.

Note: Add these two file to .gitignore file if you do not want to commit.

Hare Kumar
  • 699
  • 7
  • 23
  • Hi hkumar I have followed what you suggested, How do I know what rails version should I use with the cloned repo ? In the gemfile I mentioned `ruby "2.1.3"` and `gem 'rails', '4.2'`. I do not know how to mentioned the gemset name in the gemfile. Before I had an error with eventmachine now the problem is with installing Json (1.8.2). – Antoine Mar 27 '15 at 19:44
  • I just ran `brew update` and then `sudo gem install rails` because brew doctor caused en error and it failed to download rails. However when I ran bundle update now the error is while installing ffi (1.9.8). – Antoine Mar 27 '15 at 19:54
  • I am so confused and I have to admit nothing make sens to me regarding setting up the environment in that case. Otherwise everything works fine with my other rails projects. Should I reset the environement settings for this projects and if yes how? Thanks @hkumar . – Antoine Mar 27 '15 at 19:57
  • @Antoine: To know rails version check your Gemfile from repo. As you said , you have mentioned rails 4.2 then this is the version. You don't have to mention gemset name in gemfile. You need to create two new file .ruby-version and .ruby-gemset . And then do the bundle install. – Hare Kumar Mar 28 '15 at 09:32
  • Please follow the above instruction. – Hare Kumar Mar 28 '15 at 09:33
  • I have followed your instruction but I still get an error message: An error occurred while installing ffi (1.9.8), and Bundler cannot continue. Make sure that `gem install ffi -v '1.9.8'` succeeds before bundling. – Antoine Mar 28 '15 at 16:36
  • of course, gem install ffi -v '1.9.8' does not work. – Antoine Mar 28 '15 at 16:37
0

Can you show me some of lists? Go to 'Terminal' run 'rvm -v' run 'rvm list' run 'which ruby' run 'brew -v' run 'brew doctor'

seoyoochan
  • 822
  • 3
  • 14
  • 28
  • Thanks a lot for your time. I have updated my question in order include what you asked for. I am looking forward to read you soon ! – Antoine Mar 26 '15 at 18:06