I am updating one of rails app on my server with new content. It was working fine until the previous day. Now when I try to migrate my db using rake or use any rake commands, I get the following errors:
rake aborted!
rake aborted!
invalid byte sequence in US-ASCII
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/trace_output.rb:16:in `block in trace_on'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `map'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `trace_on'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:328:in `trace'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:183:in `display_error_message'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:169:in `rescue in standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:159:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:88:in `load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:72:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
(See full trace by running task with --trace)
My local machine ruby version is: 2.0.0p0
And my server ruby version is: ruby 1.9.3p194
Is it because I need to update my ruby version on my server to 2.0.0p0
Thanks
Add
# encoding: utf-8
to the top of your migration file.
this is one of the changes between ruby 1.9.3 and 2.0.0 - default utf-8 encoding, you should always try to develop, test and deploy on the same version of ruby (you can/should test on more rubies).
Add a system environment in the
~/.bash_profile file.
export RUBYOPT='-KU'
in my host ,it works well.
Related
I've recently joined a team on a Ruby-on-Rails application, and I try to audit the tests. There were no tests, so I decided to implement them in the app.
After seeing around what was there, I have seen there were no command to run the tests available. I ran the following command:
rails --tasks
In the output, there is no command such as rails test, rails test:system. Surprisingly, I can run the command rails test with success. But the command rails test:system --trace fails with following output:
rails aborted!
Don't know how to build task 'test:system' (see --tasks)
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task_manager.rb:59:in `[]'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:159:in `invoke_task'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
I have tried running the command in a freshly created app, and I can see the available commands rails test and rails test:system.
rails --tasks
Any idea why the command rails test:system fails? Thanks.
Ruby version: 2.3.3
Rails version: 5.2.0
EDIT:
I'm using MiniTest
To run all specs in a single go:
rspec
To execute a specific test file:
rspec <path to the file> # rspec spec/controllers/mytest_spec.rb
Use --format documentation for a formatted output.
Prepend bundle exec if rspec throws a dependency error.
at the moment I want to upgrade redmine 1.4.0 to the latest version 2.0.2.
So I followed the howto on this page:
http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade
In short I downloaded the redmine-source and extracted it in a separate folder
"/var/www/redmine-2.0.2"
(whereas my working installation is in /var/www/redmine).
up to Step 3.5 everything went fine but in 3.6
the following happens:
root(at)information:/var/www/redmine-2.0.2# rake config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
(See full trace by running task with --trace)
root(at)information:/var/www/redmine-2.0.2# rake --trace
config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:115:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake -
0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top
(required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_session_store
Invoke generate_session_store (first_time)
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time)
Execute config/initializers/secret_token.rb
Execute generate_secret_token
Execute generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_secret_token
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time, not_needed)
Execute generate_secret_token
this last step seems to generate "/var/www/redmine-2.0.2/config/initializers/secret_token.rb"
and according to the how to it is a sufficient substitute to the "rake-commands" before.
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake db:migrate RAILS_ENV=production
root(at)information:/var/www/redmine-2.0.2# rake tmp:cache:clear
root(at)information:/var/www/redmine-2.0.2# rake tmp:sessions:clear
My first prob is how to start the application. I can still go to my old installation "/var/www/redmine"
and start with
ruby ./script/server -e production &
which still works, the output is:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-
2.3.14/lib/active_support/inflector.rb:3:in `<top (required)>': iconv will be deprecated
in the future, use String#encode instead.
=> Booting Mongrel
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after
2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-
2.3.14/lib/rails/gem_dependency.rb:21.
=> Call with -d to detach
=> Ctrl-C to shutdown server
But I can't start the application by going to the new folder "/var/www/redmine-2.0.2/"
and calling
ruby ./script/server -e production &
because there is no file
"/var/www/redmine-2.0.2/script/server".
How can I start the updated version of redmine or is not possible yet ?
I think redmine 2.0.2 needs rails 3.2.5 and I thought I installed
it because:
root(at)information:/var/www/redmine-2.0.2/script# rails -v
Rails 3.2.5
root(at)information:/var/www/redmine-2.0.2/script#
According to the boot protocol above Rails 2.3.14 is used. Wrong ?
Whats my mistake here ? Can somebody give advice howto
succesfully upgrade ?
thanks for your help in advance!
Cheers,
Ansgar
Solve it by using bundle exec rails s -d -e production to start the application in background using the default port (i.e. 3000).
Update
It seems to be an RVM issue, if you open a new shell and running:
$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.
Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.
When I try to run "rake test" on my newly generated rails application I receive the following error
Computer:heroku user$ rake test:units
/Users/user
file doesnt exist
/Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require': cannot load such file -- /Users/user/test/unit/helpers/things_helper_test.rb (LoadError)
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/Users/user/.rvm/rubies/ruby-1.9.3-p0/b...]
Tasks: TOP => test:units
(See full trace by running task with --trace)
I am guessing that this is related to my setup somehow, as it seems as if rake is looking for the generated files in my home directory instead of the rails application directory. Could you help direct me to what I am doing wrong?
I am using Mac OS X Lion, have two installed ruby versions (1.8.7 come with lion, 1.9.3 which I am using for the application has been installed using rvm).
The application works if I run "rails s".
Update: If I create a new rails application from scratch, adding only a generated scaffold, the rake test command works. Ergo, it might be a incompatibility issue as the failing rails application was created on another computer, uploaded to heroku and then cloned from there to a new computer.
Funny story. I'd accidentally put some test code in one of the files, among other containing:
Dir.chdir("../..")
I'm guessing that when I run rake test the file got executed to load the class contained in the file, and caused problems when looking for the next file, when the current directory had suddenly changed.
So I've wanted to install RVM for a while on OSX. I finally got it working after figuring out I had to download the latest XCode. I installed ruby 1.9.2 and used these commands to create a new gemset in rvm:
rvm gemset create rails235
rvm 1.9.2#rails235
gem install rails -v 2.3.5
Then I went into one of my old apps that used rails 2.3.5 and tried to run some rakes and any rake I run I seem to get this error:
rake aborted!
no such file to load -- initializer
Also, semi related, right now I'm trying to get rdoc setup. I've never used before and I'm typing in "rake doc::app" and I'm getting that same error.
The full rake with --trace is this:
$ rake doc::app
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
Don't know how to build task 'doc::app'
(See full trace by running task with --trace)
brenton-wejrowskis-macbook-pro-2:bizzark wejrowski$ rake doc::app --trace
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
Don't know how to build task 'doc::app'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/task_manager.rb:49:in `[]'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:111:in `invoke_task'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `load'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `<main>'
No idea what to do next!
Your rake doc::app error is most probably due to the fact that rake tasks only use a single colon (":") to separate namespaces and task names. Try running rake doc:app instead.
I have been using ruby on rails fine no problem, now suddenly every time I run rake db:create I get the following errors:
C:\>cd xampp
C:\xampp>cd htdocs
C:\xampp\htdocs>cd what
C:\xampp\htdocs\what>rake db:create
rake aborted!
undefined method `task' for #<What::Application:0x20eb1e0>
(See full trace by running task with --trace)
C:\xampp\htdocs\what>
Any help please???
Here is all my cmd
C:\xampp\htdocs\comeon>rake db:create --trace
rake aborted!
undefined method `task' for #<Comeon::Application:0x211fb30>
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:i
n `method_missing'
C:/xampp/htdocs/comeon/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:495:in `r
aw_load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:78:in `bl
ock in load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:77:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:61:in `bl
ock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:59:in `ru
n'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'
This will help you.
gem uninstall rake
gem install rake -v 0.8.7
If Still the problem exists, uninstall rake and install using
gem uninstall rake
gem install rake
for more info
Undefined method 'task' using Rake 0.9.0
I was having the same problem, found a post by Jim Weirich in git hub that solved my problem
https://github.com/jimweirich/rake/issues/33#issuecomment-1213705
Two issues here: (1) dimitko's issue is that the built in rake command is being mixed with the new gem's library files. Arranging your $PATH environment list so that the gem version of rake has precendence over the built-in version should fix that. If you are using bundler, you might also want to try 'bundle exec rake'.
The second issue (mjansen401 and r00k above) is that the new version of rake does not put its DSL commands (task, file, desc, import, etc) in the root of the Object namespace anymore (placing them in Object meant every object has a task command, not very nice . The DSL commands are available by mixing in the Rake::DSL module into any module needing the commands.
Until rails is updated to work with Rake 0.9.x, put the following in your project Rakefile before the call to Application.load_tasks:
class Rails::Application
include Rake::DSL if defined?(Rake::DSL)
end
Let me know if these work for you.
Hope it helps