I have a rails app on Heroku. I can connect to it, push builds, and see that it's running.
The problem: I am unable to push builds that include migrations in the db>migrate folder. Any attempt to do so gives me an error of
remote: Run `bin/rails db:migrate` to update your database then try again. remote: You have 3 pending migrations: remote: 20210326003113 CreateUsers remote: 20210326004504 CreateAlerts remote: 20210326004819 CreateContacts remote: Waiting for release.... failed. To https://git.heroku.com/*appname* 3dca123..cc0f499 master -> master
I ran my migrations locally, committed, tested them locally (they work), then pushed to heroku with the same response as above.
I can run heroku run bin/rails db:migrate
which gives me a response of a bunch of warnings.
// ♥ heroku run bin/rails db:migrate -a *app name*
Running bin/rails db:migrate on ⬢ *app name*... up, run.1211 (Free)
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/rubygems_integration.rb:12: warning: already initialized constant Bundler::RubygemsIntegration::EXT_LOCK
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/rubygems_integration.rb:12: warning: previous definition of EXT_LOCK was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/version.rb:4: warning: already initialized constant Bundler::VERSION
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/version.rb:10: warning: previous definition of VERSION was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:4: warning: already initialized constant Bundler::WINDOWS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:4: warning: previous definition of WINDOWS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:5: warning: already initialized constant Bundler::FREEBSD
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:5: warning: previous definition of FREEBSD was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:6: warning: already initialized constant Bundler::NULL
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:6: warning: previous definition of NULL was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:12: warning: already initialized constant Bundler::CurrentRuby::KNOWN_MINOR_VERSIONS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:12: warning: previous definition of KNOWN_MINOR_VERSIONS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:25: warning: already initialized constant Bundler::CurrentRuby::KNOWN_MAJOR_VERSIONS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:24: warning: previous definition of KNOWN_MAJOR_VERSIONS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:27: warning: already initialized constant Bundler::CurrentRuby::KNOWN_PLATFORMS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:26: warning: previous definition of KNOWN_PLATFORMS was here
Checking the logs, it tells me it could not create a user because my user table doesn't exist. User table doesn't exist because there are no migrations. Using heroku run rake db:migrate does nothing because the build on Heroku contains no migrations. I cannot push a build with migrations because it tells me I have pending migrations.
Any assistance with this catch-22 would be lovely. Can readily post the logs if requested.
Solution was inside of my Procfile.
I needed to use bundle exec rails s.
Before I was using release: bin/rails db:migrate
Related
I am using ubuntu 18.4, Ruby 2.7.3 , rails 4.2.11.1, Rake 10.0.0
While trying to run the rake admin:create, I am getting the below error message. Can any one help me on this.
/home/ubuntu/.rbenv/versions/2.7.3/lib/ruby/2.7.0/uri/version.rb:3: warning: already initialized constant URI::VERSION_CODE
/home/ubuntu/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/uri-0.10.1/lib/uri/version.rb:3: warning: previous definition of VERSION_CODE was here
/home/ubuntu/.rbenv/versions/2.7.3/lib/ruby/2.7.0/uri/version.rb:4: warning: already initialized constant URI::VERSION
I am in the process of deploying my Rails application with Passenger and when I run this command to get my application ready and set for production I get this yarn message but no further actions are run.
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
Output from that command:
yarn install v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Lockfile not saved, no dependencies.
Done in 0.04s.
When this is finished running I hop into the Rails console and run Rails.env and the result is development. I have removed and re-installed Yarn but that is no luck. There are no Yarn dependencies so I am confused as to why I need it in the first place. If I run the bundle exec command without Yarn installed I get this message:
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
Does anybody know how to by-pass this or set this to production mode without having Yarn installed?
I have also tried running:
RAILS_ENV=production rake assets:precompile
But get this rather large input:
/var/www/isharelessons/code/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: already initialized constant FileUtils::RUBY
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: previous definition of RUBY was here
/var/www/isharelessons/code/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: already initialized constant FileUtils::LN_SUPPORTED
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: previous definition of LN_SUPPORTED was here
/var/www/isharelessons/code/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: already initialized constant Rake::FileUtilsExt::DEFAULT
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: previous definition of DEFAULT was here
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
[....]
When you run a command like
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
It will use the production environment when executing those commands, but it doesn't put you in the environment beyond the duration of that single rake command. If you then run
$ rails c
2.4.2 :001 > Rails.env
=> "development"
It's showing development, because RAILS_ENV is empty, and when empty, the default environment is development.
When you specify an environment on the command line at the end of a rake command, it doesn't change the shell's environment; it's just an argument to the rake command, and does not persist in any way.
Similarly, when you prefix a command with the environment, like
RAILS_ENV=production rake assets:precompile
It does not persist beyond that single command. It's a temporary variable assignment. That does change the shell variable, but only for the duration of that command line, and it also does not change the environment for future commands.
If you want to set the environment for your shell session, so that it affects all future commands (until you log out or start a new shell), then you have to export the variable:
$ export RAILS_ENV=production
$ rails c
2.4.2 :001 > Rails.env
=> "production"
I'm having some problem when running any rake command in my rails application:
humberto#asterix:/var/www/avante-q-a$ rake db
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:11: warning: already initialized constant DEFAULT_HOOKS
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:23: warning: already initialized constant DEFAULT_PRINT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:48: warning: already initialized constant SIMPLE_PRINT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:57: warning: already initialized constant CLIPPED_PRINT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:62: warning: already initialized constant DEFAULT_EXCEPTION_HANDLER
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:68: warning: already initialized constant DEFAULT_EXCEPTION_WHITELIST
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:71: warning: already initialized constant DEFAULT_PROMPT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:82: warning: already initialized constant SIMPLE_PROMPT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:84: warning: already initialized constant SHELL_PROMPT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:91: warning: already initialized constant NAV_PROMPT
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:107: warning: already initialized constant DEFAULT_CONTROL_D_HANDLER
/home/humberto/.rvm/gems/ruby-1.9.3-p327/gems/pry-0.9.9.6/lib/pry.rb:121: warning: already initialized constant DEFAULT_SYSTEM
rake aborted!
cannot load such file -- pry/nav
(See full trace by running task with --trace)
I've already run bundle install and it worked succesfull. Do someone know what is missing here? Thanks since now.
You should try re-running it within a bundler context:
bundle exec rake db
Bundle exec loads bundler first and hooks all of the gems into the current environment before rake is loaded.
Possible conflict with Rake extension maybe?
md:~/Dropbox_not_syncd/webs/3/tdd/rubyists$ rake db:drop
/home/durrantm/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
...
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/home/durrantm/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
..
rake aborted!
stack level too deep
(See full trace by running task with --trace)
An answer to my problems - at least they have gone away and I can move on - was to use
bundle exec rake spec
over
rake spec
Some time later....
eventually I was able to blow away my rcm or at least delete all rvm related files and then I could go back to use 'rake spec', etc. Though I did also create and repopulate the application too along with this.
I new to rails,
i've done all steps from this tutorial http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac on my ubuntu 11.04 but i'm unable to run rake db:migrate.
It gives to this output:
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList
/home/breedish/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils
rake aborted!
stack level too deep
How can i fix rake to run my initial migration
I have 1.9.2 ruby, 3.0.10 rails
thx for any help
I ran into this error recently too. Resolved it by placing bundle exec in front of the command.
bundle exec rake db:migrate
Here's a previous StackOverflow question with the same error.
And, there's more information about bundle exec here.
Try to install an older version of rake.
gem install rake -v=0.8.7
You might get a warning message when using rake.
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
You can just add "include Rake::DSL" to the Rakefile before the applications load_tasks were called.
I found a post to fix that issue.
Global access to Rake DSL methods is deprecated