I'm using the "Learn Ruby On Rails" pdf book from learn-rails.com.
I'm at chapter 13, "Configure". Where we are supposed to do the command: "rails generate figaro:install"
In chapter 12 we installed the figaro gem,: "We’ve already installed the figaro gem in the Gemfile and run bundle install."
When I run that command I get: "Could not find generator figaro:install."
I started searching for similar questions, and I did find this question here: rails generate - "Could not find generator"
where they were recommended to include "migration" into the command as well.
I included it in my command and I got it to do something, but I don't think it's doing what it should be?
invoke active_record
/Users/NormalUse/.rvm/gems/ruby-2.0.0-p353#learn-rails/gems/activerecord-4.0.2/lib/rails/generators/active_record/migration/migration_generator.rb:57:in `validate_file_name!': Illegal name for migration file: figaro:install (ActiveRecord::IllegalMigrationNameError)
(only lower case letters, numbers, and '_' allowed)
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p353#learn-rails/gems/activerecord-4.0.2/lib/rails/generators/active_record/migration/migration_generator.rb:10:in `create_migration_file'
Then about 20 more lines as well. I just didn't want to put it all here.
The author goes on to say:
"Using the rails generate command, the figaro gem generates a config/application.yml file and lists it in your .gitignore file. The .gitignore file prevents the config/application.yml file from being saved in the Git repository so your credentials are kept private."
When I go to my project directory, and look inside the "config" folder, I do have an "application" file, but it ends with ".rb" and not "yml". So obviously the command didn't do what it is supposed to do, right?
Does anyone have any ideas for me?
I'm using Ruby 2.0.0 and Rails 4.0.2 with RVM on Mac OSX 10.7.5
If you do this tutorial nowadays instead of "rails generate figaro:install" run command "figaro:install" due to figaro 1.0.0 version https://github.com/laserlemon/figaro
As you're learning (welcome to the Rails community btw!), let me explain what Figaro does & how to use (install) it:
Figaro
Figaro is a way to create ENV variables in both development & production. It's a gem which you have to install before invoking from the Rails cmd
Like other Ruby gems in Rails, you have to add it to your Gemfile, which lists all the plugins your app will use. According to RubyGems.org, you could list it in your Gemfile like this:
#Gemfile
gem "figaro", "~> 0.7.0"
After you've added this line to your Gemfile, you need to install it. To do this, you should run bundle install to run the bundler (installer)
Once you've done this, you need to run this command from cmd:
rails generate figaro:install
Error
Your errors seem to indicate you've got migration problems?
Illegal name for migration file: figaro:install
(ActiveRecord::IllegalMigrationNameError)
I would guess you called this command:
rake db:migrate figaro:install
If this is the case, you should perform any migrations by running rake db:migrate and then rails generate figaro:install. This will run the commands separately, which should help them work
Please try below one:
bundle exec figaro install
Thank you
Related
I can't launch my server with the command rails s, I have to use the command bundle exec rails s, but I prefer use the command rails s
Error when I launch the command rails s
Traceback (most recent call last):
1: from /home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `<main>'
/home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `load': cannot load such file -- /home/leopaul/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails (LoadError)
My rails version is :
Rails 5.1.6.2
I think you have multiple Rails versions installed in your machine.
Sometimes when you install a gem it comes with an executable/binary as well. Examples of these include: rails, rake, rspec, pry, etc. However, when you have multiple versions of a gem installed you then will have multiple versions of these executables sitting around. So if you want to execute one of these binaries for a given rails app you may need to disambiguate which executable you want -- the one for rake v10.1 or the one for rake v10.2, for example.
So for most commands you'll want to run bundle exec to make sure you're running the right version for your project (and also to make sure that all dependencies are also loaded from the correct versions specified in your Gemfile.lock).
So answering to your question if you are able to do bundle exec rails s and unable to do rails s try reinstalling rails gem to your local machine.
gem install rails
then check current version by rails -v
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
See docs: http://railsapps.github.io/updating-rails.html
It seems that you have installed globally is rails 4 or some other rails version and it's the reason "it doesn't execute rails s" like you say because it consider default(global rails version) rails. When you run bundle exec then it uses the rails commands from the current Gemfile, since you have rails 5 in your Gemfile then it works properly.
Also try to create gemsets for every project.
In case your case, try this:
bundle update
then excecute
rails s
Hope it will work :)
I am trying to get started with Geokit, and I ran the install command and was greeted with the following:
rails g geokit_rails:install
Could not find generator geokit_rails:install.
Any idea what's going on? I am so confused. bundle install works just fine. I run bundle exec rake db:migrate. but when I go into the console, when I try require 'geokit', I get false. I assume it's because the config file is missing? But how do I generate a sample config file to modify if the install script is failing??
The problem is that your version of the geokit-rails gem does not contain the generator. It was added with https://github.com/geokit/geokit-rails/commit/bb4261acef62a26de823c4b7306634ffb7c3381f. The latest version of the gem is 2.1.0, and as you can see here, the generators were not part of that release.
If you want to use the head version of the gem, then you can change your Gemfile to match gem 'geokit-rails', github: 'geokit/geokit-rails'.
I know this question has already been asked in these pages, but the accepted answer repeats the basic figaro instructions, without addressing the actual error. I'm a newbie, so I'd appreciate any help . . .
I've included gem 'figaro' in my Gemfile, I've run "bundle install" from my command line. But when I enter "Rails g figaro:install" at the command line, I get the error that "Could not find generator Figaro:install."
I've searched this all over the web, and all I can find are the basic instructions. Can anyone tell me why Rails can't find the generator?
Thank you.
At time of writing, it looks like the Figaro stable version has changed recently from 0.7.0 to 1.0.0.
The rails g figaro:install command is from 0.7.0, and my guess is that 1.0.0 is installed.
To check the version used:
cd path/to/a/rails/project/directory
bundle exec gem query '\Afigaro\z'
Assuming figaro 1.0.0 is being used by the app, then the figaro commands you'll be using from now on are these (these replace the commands used by Figaro 0.7.0):
figaro install # Installs figaro into your app
figaro heroku:set -e production # Copies env config from application.yml to Heroku
Figaro gem Readme tells that to install use
$ figaro install
You are using figaro:install
I got the same error in my development, This is because of figaro updated version 1.1 +. Please read the Getting Started in Figaro Gem installation part.
give the following command after bundle install
bundle exec figaro install
It will generate the following files
create config/application.yml
append .gitignore
For heroku just use:
bundle exec figaro heroku:set -e production
First of all I am not Ruby developer, hence my hopefully really simple question.
I inherited a project with the following folder structure:
Capfile
Gemfile
Rakefile
app
config.ru
config
db
doc
lib
public
script
spec
vendor
My question is:
how to run this project in local environment? I'm running MAC OS X and have Ruby and Apache installed
from the folder structure, are you able to identify framework/frameworks this project is utilising?
Thanks for you help!
Marcin
Maybe it's a Ruby on Rails project. Try these lines in the console in the project folder:
gem install bundler
bundle
rake db:create && rake db:migrate
rails s
These commands will start Rails server at localhost:3000. This project requires DB to be installed. (DB type depends on Gemfile content). Also you should check if config/database.yml file is present.
Old question, but I would open up the Gemfile and see which framework is being used. It is often the first gem in the list.
I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server