Bundle install gives errors on many gems - ruby-on-rails

when i try to run a bundle install on a catarse project on my VPS, many of the gems needed for this project returns errors and i can't install (i'm using: ruby 1.9.2p320).
for example the gems thats return error are:
thin
eventmachine
linecache19
the error is always something that begins with:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
and ends with:
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.2-p320#catarse/gems/linecache19-0.5.12 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.2-p320#catarse/gems/linecache19-0.5.12/ext/trace_nums/gem_make.out
An error occurred while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
can you help to figure out?

Some gems need to be built locally rather than simply downloaded. This means that some of the code in the gem is written in something other than ruby (usually C). The non-ruby code needs to be compiled and built locally in order to run. In those cases you'll need an environment that is capable of compiling and building that non-ruby code.
There's a good post about native gems here : http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions.
In cases like these it is usually question of tracking down which libraries need to be installed locally in order to build the gem.
I am aware of some issues with linecache19 and there are questions out there that address these, for example : Installing linecache19 for Ruby 1.9.2 via rvm.

Related

Bundle install errors and cannot continue, even after installing missing gems

I am working on multiple Ruby on Rails applications and running...
MacOS 10.15.7,
Ruby 2.6.5,
Rails 5.2.3,
In a project app directory I am trying to run a bundle install and get the following error:
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
I proceed to install the gem from the specified source and get confirmation of install
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.3
Parsing documentation for jaro_winkler-1.5.3
Done installing documentation for jaro_winkler after 0 seconds
1 gem installed
after running bundle install again, I will get the original error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210406-62421-10txxc5.rb extconf.rb
creating Makefile
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR=" clean
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR="
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h',
needed by `adj_matrix.o'. Stop.
make failed, exit code 2
Gem files will remain installed in
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3
for inspection.
Results logged to
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.3/gem_make.out
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
The error message above doesn't give me any clear indication of what is happening. Additionally there is no such directory in the location where the message says "results logged to."
This seems to be happening in multiple application directories - but with different affected gems in each directory. They are all similar in that the error reads "make sure gem succeeds before bundling", then the gem install will succeed, and then the following bundle install will fail with the same original message.
Earlier today I did a clean Ruby 2.6.5 install and updated the Xcode CLI via xcode-select --install
If I run gem which jaro_winkler I get
/Users/{username}/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/jaro_winkler-1.5.3/lib/jaro_winkler.rb
Does anyone have any information on what could be causing this? I cannot do any bundle install without this happening. Please let me know if any more information is desired.
Thank you!
You mentioned that you are using ruby 2.6.5, but the gem is attempting to be installed in 2.6.0. Check that your Gemfile has the correct Ruby version in it.
When you ran gem which, it looks you are using rbenv. Make sure that you are using the correct Ruby version in there, too. Those rubies get installed in a different directory than xcode's. Sometimes there's a .rbenv file in the dir that will set the version as well.
Just some ideas. Hopefully something sticks.
Ended up being an issue with gem install location - export PATH="/usr/local/bin:$PATH" was previously added to my .bash_profile and this was effecting where gems were installed.
Somewhere in the error message /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby is mentioned - this is the "system default" Mac version of Ruby and is not the Ruby version I was intending to use with .rbenv ( 2.6.5 ) and gem installs.
Removing the export mentioned above help resolve the issue.
edit- wording

Windows 10 Ruby on Rails Install Issue Json

Hello I am trying set up ruby on rails on my pc. Everytime i do a bundle install, I receive this error
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that gem install json -v '1.8.3' succeeds before bundling.
I am trying to use ruby 2.2.3, This is my first experience using Ruby on my pc.
Some gems need to build some native C/C++ extensions. You should install DevKit. Here's the link. And then add it to your system environment's path variable.

An error occurred while installing RedCloth (4.2.7), and Bundler cannot continue

I have an app on the Heroku Bamboo stack and have been following the instructions here (https://devcenter.heroku.com/articles/cedar-migration) for migrating to the Cedar stack.
My app has an older version of RefineryCMS (1.0.3) and I'm trying to avoid dealing with an upgrade there (for now), and so I've kept Rails at 3.0.9. Still, Ruby 1.8.7 is past EOL, so I needed to upgrade that at least. I specified 1.9.3 in my Gemfile, thus:
source "https://rubygems.org"
ruby "1.9.3"
And then I attempted to bundle install. Here's my output from that attempt:
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies....
Using rake 0.8.7
Installing RedCloth 4.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/day/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20151105-14593-x80q4a.rb extconf.rb
checking for main() in -lc... no
creating Makefile
make clean
make
compiling redcloth_attributes.c
ragel/redcloth_attributes.c.rl: In function 'redcloth_attribute_parser':
ragel/redcloth_attributes.c.rl:26:11: error: variable 'act' set but not used [-Werror=unused-but-set-variable]
ragel/redcloth_attributes.c.rl: In function 'redcloth_attributes':
ragel/redcloth_attributes.c.rl:45:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
ragel/redcloth_attributes.c.rl: In function 'redcloth_link_attributes':
ragel/redcloth_attributes.c.rl:54:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
cc1: all warnings being treated as errors
make: *** [redcloth_attributes.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/day/.rvm/gems/ruby-1.9.3-p551/gems/RedCloth-4.2.7 for inspection.
Results logged to /Users/day/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-darwin-14/1.9.1/RedCloth-4.2.7/gem_make.out
An error occurred while installing RedCloth (4.2.7), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.7'` succeeds before bundling.
Needless to say gem install RedCloth -v '4.2.7' resulted in the same error.
I found this question, Failed to build gem native extension when install RedCloth-4.2.9 install Linux, however, my issue was with RedCloth 4.2.7 (not 4.2.9) and I'm running OSX Yosemite (not Linux). There was an answer there which pertained to OSX Mountain Lion though, and I thought it was worth a try:
rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install
Obviously, I changed 1.9.2 to 1.9.3 for my purposes, and I omitted the --no-ri --no-rdoc flags. Sadly, bundle install continued to fail with the same error.
Continuing my search online, I found this article, Install RedCloth 4.2.7 gem with bundler (using ruby enterprise edition 1.8.7). Not dissuaded by the version mismatch (again, I'm using Ruby 1.9.3, not 1.8.7), I decided to try the advice I found there, to wit:
bundle config build.RedCloth --with-cflags=-w
bundle install
This time, oh joy! it worked! And I'm on to whatever's next. I thought I would share this little journey here for any others who find themselves in the same predicament. Cheers!
I was able to resolve this issue by specifying extra build options for Bundler which are applied when building RedCloth, as follows:
bundle config build.RedCloth --with-cflags=-w
bundle install

Ruby -- run a local gem server

I'm a Ruby novice working on a Rails application. We're trying to speed up our installs by running a local gem server instead of always going out to rubygems.org. I found that running the command:
gem server
sets this up, with the server running at localhost 8808. However when I add a source line for that URL to my Gemfile, and then run "bundle install", it fails after a minute or so saying:
Gem::RemoteFetcher::FetchError: bad response Not Found 404 (http://localhost:8808/gems/rake-10.3.1.gem)
An error occurred while installing rake (10.3.1), and Bundler cannot continue.
Make sure that `gem install rake -v '10.3.1'` succeeds before bundling.
If I browse to that server, I see a page saying that Rake, version 10.3.1 is installed, but when I go to the listed URL, I do get a 404 page. After running the gem install command, I still get a 404 page, but the bundle install gets a step further and fails with:
Gem::RemoteFetcher::FetchError: bad response Not Found 404 (http://localhost:8808/gems/activesupport-3.2.12.gem)
An error occurred while installing activesupport (3.2.12), and Bundler cannot continue.
Make sure that `gem install activesupport -v '3.2.12'` succeeds before bundling.
What's going on here? I have both source lines in my Gemfile, so I'd expect the bundler to go out to rubygems.org for anything it couldn't find locally, but it also seems like the gems are in fact installed locally already. Do I have to run individual installs on each gem dependency? I'm sure I'm doing something obviously wrong here, but I'm don't know what it is.
This is a decent walkthrough of a few situations you might encounter while setting up a gem server: http://guides.rubygems.org/run-your-own-gem-server/
This one isn't half-bad either, if you're looking to just use local versions of gems (though this technique doesn't set up a separate gem server): https://coderwall.com/p/tqdrhq

Can not install gem on window

When I run command: gem bundle install 'twitter-bootstrap-rails' the result is:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1/ext/v8/gem_make.out
An error occured while installing therubyracer (0.10.1), and Bundler cannot continue
Who can tell me what wrong?
That one doesn't work on windows. There is a 'static branch' of (twitter-bootstrap-rails) if I recall correctly that does, but it will cause you lots of headaches. Rails performance on windows is extremely poor anyway, so I recommend you find a linux host.

Resources