The version is:
bash-3.2$ rails -v
Rails 3.2.9
And my ruby is the built-in ruby on MacOSX:
bash-3.2$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
bash-3.2$ which ruby
/usr/bin/ruby
My problem is that in the last step of rails new ( run bundle install), it seems that rails need to connect the internet to download some packages. And usually I need 5 minutes just wait for rails to create any project using rails new.
I was wondering whether somethings is not configured well for rails on my computer.
Another strange thing is that after I finished rails new PROJECT_NAME, it shows:
Using sqlite3 (1.3.6)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
It seems that sqlite3 has already been installed, however, when I try:
bash-3.2$ bundle show sqlite3
Could not locate Gemfile
It still complains that sqlite3is not installed. Maybe that's the reason that rails new is slow (Even sqlite3 has been installed once. It still needs to download the bundle)
Before bundle install, rails asks for my system password:
Enter your password to install the bundled RubyGems to your system
But I'm still not sure whether these packages have been installed into system, as bundle show sqlite3 failed.
Does anyone have ideas about why rails new is so slow on my computer? Thanks!
Another solution is to use RVM. It is similar to rbenv. I personally use RVM. I don't and would not recommend using the gemsets. Bundler does the separation of gem versions anyway.
Check what is up with your bundle install i.e. the last step in the rails new sequence. Run this instead:
rails new appname -B
The -B flag tells rails to "skip bundle" (reference). Then go into the app folder to run:
bundle install --verbose
Check for potential errors in the output.
Using different bundler versions can give you different results. So try other versions.
gem uninstall bundler -v your-version-number
gem install bundler -v new-version-number
In 2016, we got bundler v1.12.x which is causing some users to experience slow bundle install issues. In this case, using 1.11.2 is the faster option until they fix it.
Related
I started to develop the new RoR web app and faced weird issue.
I wanted to create new app with Postgresql. So I installed the Postgres with brew and MacOS desktop app. And type rails new test-app --database=postgresql.
At this moment, I can't install bundles because there is certain
error.
An error occurred while installing pg (1.0.0), and Bundler cannot
continue.
Make sure that `gem install pg -v '1.0.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
run bundle exec spring binstub --all
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources
listed in your Gemfile.
Run `bundle install` to install missing gems.
So I can't start new app.
Is this an issue that is occurring because of the mismatch between ruby and postgres version?
And how can I create new app with postgres?
I am currently using Mac OS high Sierra, postgres 10.5, rails 5.2.1
Try to skip running Bundler: rails new test-app --database=postgresql --skip-bundle
Once you've generated your app, you'll still have to troubleshoot why pg ins't installing. The PG gem should install just fine as long as the database is there and your system can build the gem's native extensions, so my first guess is either Postgres isn't installed or it can't be found in your environment.
Either way, this does answer your question. Skip the bundle and voila - Rails will generate a new clean app for you.
I've posted some comments, but i already seen that it seems to be an error when installing postgresql via brew. It's not common, but it happens sometimes.
Here's a quick fix:
brew install libpqxx
Make sure to run also
brew update
and restart your PostgreSQL server via:
brew services restart postgresql
Also make sure to clean up brew:
brew cleanup
If the error is still there, post your Gemfile and your database.yml file as well.
Greetings!
I am new to Rails and would like to check how Spree ecommerce solution looks like before the customization. That's why I installed Ruby from RubyInstaller, DevKit, Rails, Spree etc.
During installation of state_machines gem, below error appears and the gem is eventually not installed.
C:\>gem install state_machines
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/gems/state_m
achines- 0.2.2/test/unit/node_collection/node_collection_after_being_copied_test.rb
This has impact on the bundle install of spree project later on:
Errno::EINVAL: Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/g
ems/state_machines-0.2.2/test/unit/node_collection/node_collection_after_being_c
opied_test.rb
An error occurred while installing state_machines (0.2.2), and Bundler cannot
continue.Make sure that `gem install state_machines -v '0.2.2'`
succeeds before bundling.
Current ruby version installed is:
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32] + devkit
rails version is 4.2.0
I am running on Windows environment, without any possibility to move to Linux.
I ran into this too.
Looks like state_machines has some test case files that have a newline in the name.
I'd bet that is the cause of the issue.
I've submitted a pull request over here: https://github.com/state-machines/state_machines/pull/11
In the meantime, my branch doesn't have the issue: https://github.com/jeff-hamm/state_machines
The specific fix (for the moment, until the pullrequest is accepted) is:
git clone https://github.com/jeff-hamm/state_machines
cd state_machines
bundle gem state_machines
rake install
After doing that, 'gem install spree_core' worked just fine on windows.
Keep in mind I am not planning on keeping my branch up to date (I will delete it if the request is accepted), so, that clone url won't be ideal for long
I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.
I'm using Linux so I installed Ruby using RVM.
I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?
I installed Ruby 2.0.0 with RVM:
rvm install 2.0.0
Everything seems OK, so I tried to use it:
rvm use 2.0.0-p247
But when I try to run my Rails server using rails server, I get the following message:
bash: rails : command not found
I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.
Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?
Next, I will want to upgrade also to Rails v4.
Your gemset which comes with new Ruby version is empty. Try this:
gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.
When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.
My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:
gem list | cut -f1 -d' ' > ~/gem_list
Then I switch to the newly installed one, and run this:
xargs gem install < ~/gem_list
This does a completely clean install of the gems, outside of RVM's commands.
Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.
Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.
when you install a new ruby version, you have to reinstall all the gems for that version. start of by installing bundler first. Then run bundle in your rails root directory. When you encounter no errors, you're good to start the rails server. Good luck!
run bundle install on the application root, you need to reinstall all your dependencies for the new version of Ruby.
I'm very new to Rails (and Ruby), and am having trouble installing and using gems. I'm trying to use ruby-tmdb (https://github.com/aarongough/ruby-tmdb) and there's very little documentation.
"sudo gem install ruby-tmdb" runs just fine and I can see the gem installed when I run "gem list --local"
But, when I try and run the app, I get the error "no such file to load -- ruby-tmdb".
I'm on Mac OS X Snow Leopard. Ruby 1.8.7. Rails 3.0.3. Gem 1.3.7.
Is the gem listed in your Gemfile? In Rails 3, all gem dependencies should be listed in the Gemfile, so that it is properly loaded when the app runs.
You should have something like the following line:
gem 'ruby-tmdb'
Then, run bundle install to ensure that all gem dependencies are installed, and to have Bundler save the lock file that will ensure that all copies of this application run with the same gem versions. From this point on, you will no longer have to write the require line yourself; Rails will load in all necessary gems as the environment loads.
You might get the same error even after this, but it's always worth going through the standard process to help narrow things down :)
$ sudo which gem
$ which gem
$ sudo ruby -v
$ ruby -v
Sometimes users have different gems and rubys compared to root.
A common problem is that a gem installed for ruby 1.8 by root isn't visible for the users ruby 1.9
gems for ruby 1.8 and gems for 1.9 are NOT compatible.
This probably isn't the issue but is something that may be worth considering.
I am trying to get my Instant Rails working on my Windows 7 laptop.
The error I keep getting when trying to access my site files are:
c:/rails/ruby/lib/site_ruby/1.8/rubygems.rb:779:in 'report_activate_error'
RubyGem version error: rack<1.1.0 not~> 1.0.1> <Gem::LoadError>
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:214:in 'activate'
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:1082:in 'gem'
from c:/depot/vendor/rails/actionpack/lib/action_controller.rb:34
from c://rails/ruby/lib/ruby.site_ruby/1.8/rubygems/custom_require.rb:31 in 'gem_original_require'
etc...
I have intalled Rubygems 1.3.7 and they work fine and when I run the test it works and the gem env shows that the 1.3.7 has been installed correctly.
What can I do to get this working?
Any prompt help would be VERY appreciated.
Thanks
Your rack gem is outdated. Try to run gem update rack. Or, if you use Rails with Bundler, just run bundle install in the root of your project and it will do everything for you.
I decided to write a little manual about the Ruby 1.8.7 and Rails stable installation.
Download RubyInstaller 1.8.7 from here. During the installation, check the 'Add Ruby executables to your PATH' box. After the installation, don't forget to restard cmd. Then try running ruby -v and gem -v to check for installed Ruby 1.8.7 and RubyGems 1.3.7;
Install the latest stable Rails 2.3.8 using gem install rails --no-ri --no-rdoc; Check it using rails -v;
Create a new application using rails myapp;
Test it: script/server. That's it!
gem install rack -v 1.0.1