Can't install gem using Bundler's Rakefile install task when developing a custom gem
Yes, it has something to do with your PATH variables. Your installation seems to be good.
I advise you to first affirm your gems installation path with:
echo $GEM_HOME
The double check your PATH to ensure its present and also confirm that the GEM home is also where the gem got installed into from the rake install
echo $PATH
If not, put it in your path and you should be fine with something like this:
echo PATH=$PATH:$GEM_HOME >> ~/.bashrc
source ~/.bashrc
Rake task for installing gem migrations executing only once
The invoke
method only runs "as needed", which basically means that once it's run once, it wont run again unless reenabled.
You can either call .reenable
after each .invoke
to reset it, or use the .execute
command to run the task.
The caveat with .execute
is that it won't run the dependencies for the task if you have them.
Why is Rake not able to invoke multiple tasks consecutively?
How to run Rake tasks from within Rake tasks?
rails aborted Don't know how to build task 'AdminUser.create!()
There are several ways to add that admin into the database:
rails console
- Just open the console and executeAdminUser.create!(...)
.seeds.rb
- Open thedb/seeds.rb
file and pasteAdminUser.create!(...)
. Then runrake db:seed
. Note that runningrake db:seed
multiple times will create that admin multiple times - it's best you have some sort of validations or useAdminUser.find_or_create_by(...)
instead.- rake task - create a rake file in
lib/tasks
, name is not important but it should end in.rake
(ex:update.rake
)
task :add_admin do
AdminUser.find_or_create_by(email: "admin@gmail.com", password: "password", password_confirmation: "password")
end
Run it with rake add_admin
.
If you want that admin only for yourself, your local machine, use the console approach, otherwise pick the other two but make sure the rake tasks are idempotent.
Installing gems tries to load the gems in my custom rake tasks before installing it
this might work? delay the requires on your rake task by moving them into the task itself
task :fixtures => [:environment] do
require 'rubygems'
require 'ya2yaml'
# ...
by default running rake tasks 'loads' all of the rake files
Local rake tasks require development gems to be in production group
Maybe not the most exciting answer but I just moved the require 'dev_gem'
inside the rake task
block for that task.
namespace :elasticbeanstalk do
desc 'Creates a new web & worker environment pair for testing'
task :create do
require 'aws-sdk-elasticbeanstalk'
# Do stuff with beanstalk that we wouldn't from a production env
end
end
This way the library only gets loaded when the rake task is invoked rather than when the rake task is defined.
Related Topics
How to Use Ffmpeg on a Remote Machine via Ssh
Ruby Inserting Key, Value Elements in Hash
Gem Install Dm-Postgres-Adapter Build Error
Bundle Install Tries to Use Cache File
What's the Best Way to Start a Background Process, That Can Get Accessed Later On
Ruby/Rails Collection to Collection
Unwanted Form Parameters Being Appended to Pagination Links
What's The Most Efficient Way Get The First Day of The Current Month
Find Out Which Gems Require Native C Extensions from a Gemfile
Anything Speaking Against the Bitnami.Org Ruby/Rails/Redmine Stack
Converting External CSS to Inline CSS for Mail in Rails
Accessing Headers from Sinatra
How to Use Your Own MySQL Database Server with Heroku