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
Related
I am creating an application on ruby on rails:
After creating users, for validating users I am running below commands:
$ bundle exec rake db:migrate
$ bundle exec rake test:prepare
Both command are run properly on the rails commandLine, but when I run the below command:
$ bundle exec rspec spec/models/user_spec.rb
I am getting error below:
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
And I am using 4.1.1 version of rails.
I don't understand why it comes.
Kindly suggest me, waiting for your reply.
Thanks.
More a note for posterity than anything, but this issue can also happen if you're using an older version of shoulda-matchers. You can see some discussion around this on their Github repo here, or on the rspec-rails repo here.
Update shoulda-matchers by running bundle update shoulda-matchers. You want the latest version (or at least 2.6.2) and this message should go away.
Include minitest gem in your 'Gemfile' and run bundle install
gem install 'minitest'
and then bundle install
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
I'm in trouble with deployment of my ruby-on-rails app on heroku.
Deploy failed with following logs.
Starting process with command bundle exec thin start -R config.ru -e staging -p 6882
bash: bundle: command not found
And I noticed when deploy, bundler(1.3.2) is removed and bundler(1.5.2) is used even if I specify bundler version as '1.3.2'.
When deploy, Using bundler(1.5.2) is shown but there is no bundler in heroku run 'gem list'.
This is happen after I pushed the commit that includes some gem's updates.
After that deploy, all deploys are failed even if I deloy the commit that worked well before.
Do you have a ruby definition in your gemfile like so?
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.15'
.....
if you do, heroku will try to load bundler 1.5.2
try to update bundler like so
gem update bundler
then commit & push to heroku
I hope that helps
Thank you, everyone.
I fixed up this problem.
I tried all solutions in this post but couldn't get fixed, so I asked the heroku's support with detail information.
It is because I'm using the custom buildpack that not support Bundler 1.5.2.
So, I configure an app to use the Official Ruby Buildpack
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby
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
I am trying to install the spree gem using the following instructions
http://spreecommerce.com/resources/quick-start
The install worked fine, but trying to create an application doesn't resolve
bash: spree: command not found
PATH is
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/bin:/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0#global/bin:/Users/sandbox1/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/sandbox1/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/usr/X11/bin
bash-3.2$
Should I add something from the below output to my PATH?
bash-3.2$ find $HOME -name spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/doc/spree-0.30.0/rdoc/lib/generators/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/doc/spree_auth-0.30.0/rdoc/lib/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/doc/spree_core-0.30.0/rdoc/lib/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree-0.30.0/lib/generators/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_auth-0.30.0/app/controllers/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_auth-0.30.0/lib/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_core-0.30.0/app/controllers/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_core-0.30.0/app/helpers/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_core-0.30.0/lib/spree
/Users/sandbox1/.rvm/gems/ruby-1.9.2-p0/gems/spree_core-0.30.0/public/images/spree
bash-3.2$
What Chris said: You can create a rails 3.0 app and add the spree gem to the app, as documented in http://spreecommerce.com/documentation/getting_started.html#creatinga-new-spree-project.
Create you project with e.g., rails new spreetest
Add gem 'spree' to the Gemfile
Perform bundle install to install missing gems
Initialize the spree site with rails g spree:site and rake spree:install
Optionally, install sample data rake spree_sample:install
Populate the database with rake db:bootstrap
Run the server with rails server
From what I read on Spree homepage, they recommend you to perform the Gem installation using sudo. However, RVM says you should not use sudo. Try installing the Gem again, this time without sudo.