I'm seeding a development database (mysql) using rake db:seed in Rails 3. The rake task fails, stating,
Validation failed: Logo /var/folders/.../logo.png is not recognized by the 'identify' command.
When I run which identify, I get the expected path /usr/local/bin/identify. ImageMagick is indeed installed (via Homebrew), and appears to work with png images just fine from the command line.
I even rebuilt the app on another machine, thinking that my environment is borked, and I got the same error.
Is there a poltergeist in my terminal sessions?
Have you tried running a bundle exec before the rake. In the past this has often solved these sorts of problems for me. It will ensure your rails environment is loaded before running the rake task.
bundle exec rake db:seed
Hope that helps!
// Addition
Also are you using the Paperclip gem to do this import? I do remember that I needed to ensure the path to ImageMagick was set in my development.rb file to ensure this was picked up.
Eg.
Paperclip.options[:command_path] = "/usr/local/bin"
Related
RAIL_ENV= testing or development server looks proper, but on production server not show proper GUI
As per the images shared it seems that the css and styling is not working in production environment.
For it to work, following command would be used:
RAILS_ENV=production rake assets:precompile
Reload the page and check if the css and js rules are being picked or not.
If you're using heroku perhaps you could try it on heroku. First run RAILS_ENV=production rake assets:precompile then run git add . within your working folder. Commit, push and then push to heroku master. See if you still have this issue.
I'm migration my gitlab to another server. the old gitlab server use postgresql and the new gitlab server use mysql.
I'm convert it with tools calld “DBConvert for MySQL & PostgreSQL”.
Database had sucess convert , and the repo files also copyd to the new gitlab server.
But my projects can't use , when click the projects it notice http code 500.
In gitlab Health check ,it notice
Migrations are pending.
To resolve this issue, run: bin/rake db:migrate RAILS_ENV=production"
And when I run this cmd , it notice "No Rakefile found"
How to proceed from there?
Make sure to execute bin/rake db:migrate RAILS_ENV=production from your GitLab-CE installation folder.
Or try from the same GitLab folder:
bundle exec rake db:migrate RAILS_ENV=production"
my src and dst gitlab version are 8.8.4 , it's the same
In that case, simply do not execute any db:migrate RAILS_ENV=production: that will avoid creating duplicate tables.
Problem is resloved , see link How to resloved "Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=production".
Just getting started with Capistrano 3, and I noticed on one of my first deploys for my_app that it was complaining about the MySQL database not existing.
DEBUG [aec39935] ActiveRecord::NoDatabaseError: Unknown database 'my_app'
Well that's expected, since this a brand new deploy to a clean server. I included the capistrano-rails gem that's meant to take care of db migrations
require 'capistrano/rails/migrations'
I'd expect it to run db:create before db:migrate so that the database is created, but looks like it doesn't.
Is there a way for me to manually add this in, or reconfigure it so that it does run it?
Thanks.
To my knowledge, you can either create a special task to do this, or just run db:setup manually once. I'd personally recommend the latter.
If you want to make a custom task, take a look at the rails/migration task as an example: https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake#L15
I recently pulled some code and ran rspec. The tests passed with no problem. When I ran "rake db:migrate" and "rake db:prepare" however, I got an issue.
Now no rspec test passes, and every failure cites the same error:
Mysql2::Error: Table 'app_test.admins' doesn't exist: SHOW FULL FIELDS FROM `admins`
The thing is, that database name is not specified anywhere in the code. In database.yml, 'app_test' is specified, with no '.admins' suffix.
Similarly, when I run rails server, I get the following error:
Mysql2::Error: Table 'app_dev.admins' doesn't exist: SHOW FULL FIELDS FROM `admins`
Only 'app_dev' is specified in yml.
The rake commands (db:migrate, db:test:prepare, db:create, db:drop, etc.) are all modifying the database.yml specified databases, it's just that Rails is looking for databases with the '.admins' suffix. Where is this '.admins' suffix coming from and how can I remove it?
app_test and app_dev are database names.
it's just that Rails is looking for databases with the '.admins'
suffix.
Actually app_test.admins and app_dev.admins are tables that rails is looking for in the two databases. Couple of approaches that I would try:
rake db:create
rake db:migrate
or
rake db:schema:load
The issue was as follows:
When I pulled the code, for whatever reason, the 'Admins' table disappeared from db/schema.rb. This table cannot be restored via rake:db:migrate because the migration that created it uses t.database_authenticatable, which has been deprecated and no longer works with the Devise gem. Because we're building on legacy code, we only run rake db:migrate on recently changed migrations, never from an empty database (for an empty database, we use rake db:schema:load).
Since the table was missing from db/schema.rb it would not be restored even if I used rake db:schema:load. To fix the issue, I had to use git reset to revert to an old version of db/schema.rb.
To fix the Devise deprecation issue so that you can run all of your migrations, go here - https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
Is rake db:prepare a valid command? Did you try rake db:create:all?
Is it possible that your rails-settings-cached is configured to use admin table? Do you remember typing rails g settings admin?
Check in your models for a admin.rb file, or for a model that derivates from RailsSettings::CachedSettings
Check your initializers for the same gem as well
I've made a NSIS script to create an installer for a Rails application.
The application uses JRuby and Java.
In the first section of the installer I set the environment variables: I add jruby\bin to PATH and I create JAVA_HOME variable, which points to Java\jre6.
!define JRubyBinPath "$PROGRAMFILES\${PRODUCT_PUBLISHER}\JRuby\jruby-1.6.3\bin"
Function SetEnvVars
# set JAVA_HOME
${EnvVarUpdate} $0 "JAVA_HOME" "A" "HKCU" "C:\Program Files\Java\jre6"
# add jruby to Path
${EnvVarUpdate} $0 "Path" "A" "HKLM" "${JRubyBinPath}"
FunctionEnd
Section "Pre" SEC01
Call SetEnvVars
...
SectionEnd
** All the paths are correct. **
In the second section of the installer, after packing all the application files and JRuby files, I initialize the database using the following commands:
Section "Installer" SEC02
...
SetOutPath $INSTDIR
nsExec::ExecToLog "jruby -S bundle exec rake db:create RAILS_ENV=production"
nsExec::ExecToLog "jruby -S bundle exec rake db:migrate RAILS_ENV=production"
nsExec::ExecToLog "jruby -S bundle exec rake db:seed RAILS_ENV=production"
...
SectionEnd
The problem is that when I run the installer on a clean Windows system, all the code executes correctly, except for the lines that contain commands using "jruby". I get no error in the installer window, it just won't execute those lines.
Anyway, if I manually run those commands in a console right after the installer finishes, everything works as expected.
From what I have seen so far, the problem is that the installer cannot access the environment variables until it finishes.
* What I have done so far to solve this problem is creating the main installer Installer.exe (here I pack all the files and I set the environment variables), and another executable Init.exe which initializes the database.
If I manually run these executables - first Installer.exe then Init.exe - the application installs correctly. But if I try to launch Init.exe from Installer.exe, it won't work.
However, if there would be a way to execute the "jruby" commands in a new/different thread than the one that sets the environment variables, I think the problem would be solved. But I still couldn't find the way to do that.
Thanks.
NSIS doesn't have any threading. Apparently not quite true—but in your own code, you don't get to use threads.
You may need to set PATH for the current process; I'm not familiar with ${EnvVarUpdate}, but looking at its script it doesn't seem to updates the variable in the current process. Try this:
${EnvVarUpdate} $0 PATH A HKLM "${JRubyBinPath}" # The line you already have
System::Call Kernel32::SetEnvironmentVariable(t"PATH",tr0)
Another note: you are hard-coding JRubyBinPath; are you sure you really want to do that?