New Rails Project: 'bundle install' can't install rails in gemfile - ruby-on-rails

I have installed a new rails project like so:
$ rails new site
and it executes and reaches:
bundle install
but then I get this error, when it appears to try installing a dependency
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/mikeguppy/.bundler/tmp/26234/gems/atomic-1.1.16 for inspection.
Results logged to /Users/mikeguppy/.bundler/tmp/26234/extensions/universal-darwin-13/2.0.0/atomic-1.1.16/gem_make.out
An error occurred while installing atomic (1.1.16), and Bundler cannot continue.
Make sure that `gem install atomic -v '1.1.16'` succeeds before bundling.
I have then tried installing atomic independently with:
gem install atomic
and again no luck.
I'm running Ruby 2.0 on Mac OS 10.9.2
Any help would be much appreciated!

this worked for me:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install rails

I had this same problem and what worked for me was installing RVM, installing Ruby 2.1.1 (an upgrade from the 2.0 that comes packaged in Mavericks)...
rvm get stable
rvm reinstall 2.1.1
(use whatever the latest version is, for me that's 2.1.1)
...and then run rvm use 2.1.1 to make sure that I had switched to using that version.
After that, my gem installs ran smoothly.

This appears to be an issue relating to the system Ruby that is packaged with Mavericks (2.0.0p247), see details about the bug here: https://bugs.ruby-lang.org/issues/9624
I got around this by installing rbenv (or RVM if you prefer) and then installing Ruby 2.1.1 so as not to tamper with the system Ruby version. You will still get a warning during the installation of the atomic gem but it won't fail at least.
rbenv here: https://github.com/sstephenson/rbenv

I had the same problem when installed rails.
My ruby version is 1.9.3 p448 and OS is OS X Mavericks (10.9.2).
Here's what I tried and it works.
$ gem install rails --version 4.0.4
[ref]
http://ruby.railstutorial.org/chapters/beginning#top

First uninstall any existing atomic gem
gem uninstall atomic
Then reinstall it using
gem install atomic -v '1.1.16'
After this try to create a new rails application
rails new projectname
I don't know which version of Rails you are currently using. Sometimes, re-installing Rails to a stable version seems to help. You may want to try that as well if the above steps didn't resolve the issue.

I had a similar problem recently and it was because Xcode updated automatically to 5.1. This version contains a bug/problem with gcc.
The clue is here:
-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning)
Sadly I had to downgrade Xcode - available here.

Ruby 2.1.5 on Maverick via rvm installed atomic 1.1.16 without issue.

This error can occur if you are bundling with the wrong version of ruby for the bundle. Check the Gemfile for the ruby version and then check the output of ruby -v. If there is a version mismatch, use rvm to make sure you are using the same version of ruby, then re-bundle.
I got this exact error and fixed it by changing the version of ruby I was using.

None of these worked for me. I came up with my own solution. The problem lies in json versions less than 2.0. When I tried to upgrade json, I got an error message about dependency issues with rails and sdoc. Here's what I ended up doing:
Open your Gemfile.
Comment out the lines for sdoc and rails.
Add this line:
gem 'json', '> 2'
Run bundle install.
Worked for me.

Related

Rails installation fails while running make nior4

I’m trying to install the current stable version of rails (5.2)
gem install rails
but it fails:
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /Users/ms1/.rvm/gems/ruby-2.4.1/gems/nio4r-2.1.0/ext/nio4r
[…]
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */
^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
[…]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
9 warnings and 20 errors generated.
make: *** [nio4r_ext.o] Error 1
make failed, exit code 2
I’m on Mac OS X HighSierra (10.13.2) and I’ve installed Xcode (9.2) with developer / command-line tools (9.2), rvm 1.29.3, Homebrew 1.4.0, bundler 1.16.0, nokogiri 1.8.1.
I’m on ruby 2.4.1, but tried 2.4.2, 2.3.0, 2.2.2 as well, always with the same result.
Installing nio4r manually results in the same problem:
gem install nio4r
[…]
ERROR: Failed to build gem native extension.
Some answers on StackOverflow suggested
gem install nio4r -v '1.1.0' -- with-cflags="-std=c99"
which did not work, either.
Interestingly,
rails
gives me the following output on my machine:
Ignoring bigdecimal-1.3.2 because its extensions are not built.
Try: gem pristine bigdecimal --version 1.3.2
Rails is not currently installed on this system. To get the latest version, simply type: sudo gem install rails
Of course I tried both of the above mentioned hints, too; both result in the same problem as stated initially.
As I'm running out of ideas here and couldn't find any other helpful advice, I'm really looking forward for any ideas on this!
Filing an issue on nio4r's Github page solved my problem: There was an old port.h file from an abandoned Postgres installation in /usr/local/include/ on my system which was causing the trouble.
Removing /usr/local/include/port.h allowed me to install Rails!

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

not able to install ruby on rails in OSX mavericks

I have OSX mavericks and I was trying to install ruby on rails .First I tried Installing via RailsInstaller (http://railsinstaller.org/en) ,There was a notice in the website saying "Please do not run the installer on OSX Mavericks until further notice."
Then I tried installing using rvm which turned out to be a night mare .
I followed instructions from all the below links none seem to work
Installing Rails on Mavericks
Xcode install on OSX 10.9 - clang: error: no input files
Installing Rails on Mavericks
http://railsapps.github.io/installrubyonrails-mac.html
I have installed Xcode 5.0 and I have even manually downloaded Command lines tools
https://developer.apple.com/downloads/index.action
when I try
rails -v
I get a message
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
Then I tried command for which I got an error message
Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for libkern/OSAtomic.h... yes creating Makefile
make "DESTDIR=" compiling atomic_reference.c atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~ /usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
I'm not able to use xcode-select --install either which says the software is not present in the server
Please guide on how to install rails on my osx mavericks ?
Rails 4 needs RubyGems 2.0.3. Update it and you should be good to go.
gem update --system 2.0.3
Then,
gem install rails
Hope it helps.

bundle throwing error Gem::Installer::ExtensionBuildError: ERROR: with Mavericks and ruby 2.0

Getting the below error when i run bundle from a 1.8.7 app. I just upgraded to Mavericks and am using rbenv.
Things I've tried already:
1) uninstall and reinstall rbenv and ruby-build
2) dropped the directory and re-cloned
3) installing x-code cli with xcode-select --install
4) brew install apple-gcc42
5) deleting the root ruby file (2.0) and replacing with 1.8
6) brew unlink apple-gcc42
None of the above have worked yet.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for re.h... no
creating Makefile
make "DESTDIR="
compiling parser.c
parser.rl:165:20: error: expected '(' after 'if'
if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:445:18: note: expanded from macro 'RTEST'
#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
^
1 error generated.
make: *** [parser.o] Error 1
Gem files will remain installed in /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6 for inspection.
Results logged to /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6/ext/json/ext/parser/gem_make.out
An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.4.6'` succeeds before bundling.
I just got something similar when I changed an old Ruby 1.9.3 project to Ruby 2.2.0 and tried to bundle.
I got errors like parser.rl:139:20: error: expected '(' after 'if'" and " and accept.c:128:2: error: use of undeclared identifier 'TRAP_BEG'.
The fix was to upgrade the gems that failed to build: bundle update json kgio in my case, where the json gem and then the kgio gem failed to build.
If you've locked down the versions of a problematic gem in your Gemfile, you might want to unlock them, too. E.g. change gem "json", "1.1.6" to just gem "json". Though you should of course make sure you know why it was locked down in the first place.
When you just do bundle, it tries to install/build the gem versions listed in Gemfile.lock. Those will be the versions you installed previously on Ruby 1.8.7 in your case, or 1.9.3 in my case. I guess those gem versions are old enough that they simply don't compile for a newer Ruby.

Rails install ERROR: Failed to build gem native extension

I am trying to install rails on my mac, but every time I type sudo gem install rails into the command line, I get the following error message. I have been stuck for a while, hope you can help.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.14 for inspection
Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
If you are trying to install Rails 4.0, it needs RubyGems 2.0.3, so you have to update your system by using following command
gem update --system 2.0.3
and then continue with your installation.
Hope it helped
I would just use rvm. It should work like a charm. Or you could dig around and see if you can find that ruby.h file its talking about. But I personally think the latter would be a pain in the ass.
Upgrade xcode by typing following command in terminal window-
xcode-select --install
This should solve your isssu.
yea the rvm works like a charm and it will come in handy when you want to switch between different rails versions
I had the same issues. I upgraded my version (using RVM) of Ruby from 2.0.0-p195 to 2.0.0-p353 (make sure you tell RVM to use the new version as the default). After this I did gem install rails again and it worked fine.
Make sure you have installed the right version of DevKit, you can get it from here...
http://rubyinstaller.org/downloads/
and install as it says here:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit#installation-instructions
if you still have the problem even after Upgrading Xcode.
Its may be because :
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
Personally I have got this problem while installing json gem , I did :
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
And the problem was solved.

Resources