0

I'm new to Ruby on Rails and am having trouble setting up my first MySQL database.

I followed the instructions on here: https://gorails.com/setup/osx/10.12-sierra

And I reached the very end where it asks you to run "rake db:create". When I execute this in the terminal, I get the following error:

MacBook-Air-de-myusername% rake db:create
rake aborted!
cannot load such file -- bundler/setup
/Users/myusername/splash/config/boot.rb:3:in `<top (required)>'
/Users/myusername/splash/config/application.rb:1:in `require_relative'
/Users/myusername/splash/config/application.rb:1:in `<top (required)>'
/Users/myusername/splash/Rakefile:4:in `require_relative'
/Users/myusername/splash/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Can anyone advise on what is happening? I know that I have "cd"-ed into the correct directory, so that can't be it.

reallymemorable
  • 882
  • 1
  • 11
  • 28

3 Answers3

1

Install bundler gem and run bundle install:

$ gem install bundler
$ bundle install

Now run rake again:

$ rake db:create

If that doesn't work, then run the complete command:

$ bundle exec rake db:create

To understand more about bundle command, check this question.

Community
  • 1
  • 1
Gerry
  • 10,337
  • 3
  • 31
  • 40
  • I ran into an error on "bundle install" because it says it doesn't work with Ruby 2.0.0. The thing is, I've already installed 2.4.0. However: when I run "ruby -v" it says it's 2.0.0, but when I try to (re)install 2.4.0 it says: `rbenv: /Users/myusername/.rbenv/versions/2.4.0 already exists` – reallymemorable May 13 '17 at 18:33
  • Rbenv. I tried to do RVM but ran into some errors that a noob like myself couldn't figure out. – reallymemorable May 13 '17 at 18:38
  • @7QVM OK, try running `rbenv global 2.4.0` to change your ruby version. Then run `bundle install` again (check first with `ruby -v` that your version changed successfully). – Gerry May 13 '17 at 18:41
  • It doesn't seem to have had any effect: `MacBook-Air-de-myusername% rbenv global 2.4.0 MacBook-Air-de-myusername% ruby -v ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]` – reallymemorable May 13 '17 at 18:43
  • @7QVM Did you specified a `RBENV_VERSION` variable? If so, run `echo $RBENV_VERSION` to see which version it specifies; if it is `2.0.0` change it to `2.4.0`. – Gerry May 13 '17 at 18:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144145/discussion-between-gerry-and-7qvm). – Gerry May 13 '17 at 18:59
0

Run:

gem install bundler
bundle install
bundle exec rake db:create
Rakesh
  • 284
  • 2
  • 5
0

I think you are in incorrect folder.

try cd splash

then run following command:

bundle install
bundle exec rake db:create
puneet18
  • 4,341
  • 2
  • 21
  • 27