missing rake tasks? - ruby-on-rails

I have ran gem install rails and am running 2.3.4
but i am missing some rake tasks like 'db' and 'gems'
if i run rake -T i get the following tasks. How can i get all the others ?
rake apache2 # Build Apache 2 module
rake clean # Remove compiled files
rake clobber # Remove all generated
files
rake default # Build everything
rake doc # Generate all documentation
rake doxygen # Generate Doxygen C++
API documentation if ...
rake doxygen:clobber # Remove
generated Doxygen C++ API documenta...
rake doxygen:force # Force generation
of Doxygen C++ API docume...
rake fakeroot # Create a fakeroot,
useful for building nat...
rake nginx # Build Nginx helper server
rake package # Build all the packages
rake package:clean # Remove package
products
rake package:debian # Create a Debian
package
rake package:force # Force a rebuild
of the package files
rake package:gem # Build the gem file
passenger-2.2.4.gem
rake rdoc # Build the rdoc HTML Files
rake rdoc:clobber # Remove rdoc
products
rake rdoc:force # Force a rebuild of
the RDOC files
rake sloccount # Run 'sloccount' to
see how much code Passe...
rake test # Run all unit tests and
integration tests
rake test:cxx # Run unit tests for the
Apache 2 and Nginx ...
rake test:integration # Run all
integration tests
rake test:integration:apache2 # Run
Apache 2 integration tests
rake test:integration:nginx # Run
Nginx integration tests
rake test:oxt # Run unit tests for the
OXT library
rake test:rcov # Run coverage tests
for the Ruby libraries
rake test:restart # Run the 'restart'
integration test infinit...
rake test:ruby
If anyone knows why this has happened, how i can fix it or anything else that could help, please let me know
thanks alot
rick

seems like the rake tasks for mod_rails.
To run the tests for rails go to rails folder.

Related

Don't know how to build task 'routes'

I can't execute rake routes even if the routes.rb file is empty. This is the output:
➜ rake routes
rake aborted!
Don't know how to build task 'routes' (See the list of available tasks with `rake --tasks`)
(See full trace by running task with --trace)
Output from rake about:
➜ rake about
About your application's environment
Rails version 6.1.0
Ruby version ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
RubyGems version 3.1.4
Rack version 2.2.3
Middleware Webpacker::DevServerProxy, Rack::MiniProfiler, ActionDispatch::HostAuthorization, Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::ActionableExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, ActionDispatch::PermissionsPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, Warden::Manager
Application root /Users/cobexa/app
Environment development
Database adapter postgresql
Database schema version 20201219225707
And output from rake --tasks:
rake about # List versions of all Rails frameworks and the environment
rake action_mailbox:ingress:exim # Relay an inbound email from Exim to Action Mailbox (URL and INGRESS_PASSWORD required)
rake action_mailbox:ingress:postfix # Relay an inbound email from Postfix to Action Mailbox (URL and INGRESS_PASSWORD required)
rake action_mailbox:ingress:qmail # Relay an inbound email from Qmail to Action Mailbox (URL and INGRESS_PASSWORD required)
rake action_mailbox:install # Installs Action Mailbox and its dependencies
rake action_mailbox:install:migrations # Copy migrations from action_mailbox to application
rake action_text:install # Copy over the migration, stylesheet, and JavaScript files
rake action_text:install:migrations # Copy migrations from action_text to application
rake active_storage:install # Copy over the migration needed to the application
rake app:template # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake app:update # Update configs and some other initially generated files (or use just update:configs or update:bin)
rake assets:clean[keep] # Remove old compiled assets
rake assets:clobber # Remove compiled assets
rake assets:environment # Load asset compile environment
rake assets:precompile # Compile all the assets named in config.assets.precompile
rake cache_digests:dependencies # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake cache_digests:nested_dependencies # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake db:create # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to creating the development and test databases, except when DATABASE_URL is present
rake db:drop # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to dropping the development and test databases, except when DATABASE_URL is present
rake db:environment:set # Set the environment value for the database
rake db:fixtures:load # Loads fixtures into the current environment's database
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rake db:migrate:down # Runs the "down" for a given migration VERSION
rake db:migrate:redo # Rolls back the database one migration and re-migrates up (options: STEP=x, VERSION=x)
rake db:migrate:status # Display status of migrations
rake db:migrate:up # Runs the "up" for a given migration VERSION
rake db:prepare # Runs setup if database does not exist, or runs migrations if it does
rake db:reset # Drops and recreates the database from db/schema.rb for the current environment and loads the seeds
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake db:schema:cache:clear # Clears a db/schema_cache.yml file
rake db:schema:cache:dump # Creates a db/schema_cache.yml file
rake db:schema:dump # Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)
rake db:schema:load # Loads a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`) into the database
rake db:seed # Loads the seed data from db/seeds.rb
rake db:seed:replant # Truncates tables of each database for current environment and loads the seeds
rake db:setup # Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)
rake db:structure:dump # Dumps the database structure to db/structure.sql
rake db:structure:load # Recreates the databases from the structure.sql file
rake db:version # Retrieves the current schema version number
rake log:clear # Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
rake middleware # Prints out your Rack middleware stack
rake restart # Restart app by touching tmp/restart.txt
rake secret # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
rake stats # Report code statistics (KLOCs, etc) from the application or engine
rake test # Runs all tests in test folder except system ones
rake test:all # Runs all tests, including system tests
rake test:db # Run tests quickly, but also reset db
rake test:system # Run system tests only
rake time:zones[country_or_offset] # List all time zones, list by two-letter country code (`bin/rails time:zones[US]`), or list by UTC offset (`bin/rails time:zones[-8]`)
rake tmp:clear # Clear cache, socket and screenshot files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear, tmp:screenshots:clear)
rake tmp:create # Creates tmp directories for cache, sockets, and pids
rake webpacker # Lists all available tasks in Webpacker
rake webpacker:binstubs # Installs Webpacker binstubs in this application
rake webpacker:check_binstubs # Verifies that webpack & webpack-dev-server are present
rake webpacker:check_node # Verifies if Node.js is installed
rake webpacker:check_yarn # Verifies if Yarn is installed
rake webpacker:clean[keep,age] # Remove old compiled webpacks
rake webpacker:clobber # Remove the webpack compiled output directory
rake webpacker:compile # Compile JavaScript packs using webpack for production with digests
rake webpacker:info # Provide information on Webpacker's environment
rake webpacker:install # Install Webpacker in this application
rake webpacker:install:angular # Install everything needed for Angular
rake webpacker:install:coffee # Install everything needed for Coffee
rake webpacker:install:elm # Install everything needed for Elm
rake webpacker:install:erb # Install everything needed for Erb
rake webpacker:install:react # Install everything needed for React
rake webpacker:install:stimulus # Install everything needed for Stimulus
rake webpacker:install:svelte # Install everything needed for Svelte
rake webpacker:install:typescript # Install everything needed for Typescript
rake webpacker:install:vue # Install everything needed for Vue
rake webpacker:verify_install # Verifies if Webpacker is installed
rake webpacker:yarn_install # Support for older Rails versions
rake yarn:install # Install all JavaScript dependencies as specified via Yarn
rake zeitwerk:check # Checks project structure for Zeitwerk compatibility
I just discovered that rake routes were deprecated on rails 6.1 in favor of rails routes: https://github.com/rails/rails/commit/41ad613e4c5d6c05f20ac0437564ff0d31ab9f5a
bin/rake routes is deprecated. You can Use bin/rails routes
You can try using rails routes instead of rake routes.
You can use rails routes --expanded for a very clean output even on small screens.

How to 'rake spec' one directory, e.g. models?

I can rake spec and all specs run.
However trying to run specs for one directory, as in
rake spec/models/ or rake spec/models/*.rb
does not provide any output or errors.
One option is that I can do
rspec spec/models/*.rb
or
rspec spec/models/
but I was wondering if I could stay within Rake.
Try rake spec:models instead of rake spec/models. Run rake -T | grep spec to see all the available rake spec tasks.
UPDATE: Running your specs through rake spec may be slower than running them through rspec spec, said by the rspec-rails guys. Read de installation section of rspec-rails.
Use SPEC env. variable:
rake spec SPEC=spec/models

How to load db rake tasks in rails 3.2.9 engine

We are working on rails engine on 3.2.9. Engine is generated with :
rails plugin new rails_engine -mountable --skip-test-unit --dummy-path=spec/dummy
After initial setup, we can generate a model just like what we do in regular rails app:
rails g model post name:string
There is a migration file created under db/migrate/. Next we did db:migrate under the/ rails_engine :
rake db:migrate
It causes error:
Don't know how to build task 'db:migrate'
List available rake tasks:
bundle exec rake --tasks
rake build # Build test_itemx-0.0.1.gem into the pkg directory
rake clobber_rdoc # Remove RDoc HTML files
rake install # Build and install test_itemx-0.0.1.gem into system gems
rake rdoc # Build RDoc HTML files
rake release # Create tag v0.0.1 and build and push test_itemx-0.0.1.gem to Rubygems
rake rerdoc # Rebuild RDoc HTML files
There is no db:migrate among them. The question is how to load db tasks back to rake.
This is the expected behavior. Remember that it is a mountable engine. It does not have an environment of it's own. You need to mount it to a Rails application (Not an engine but an actual app). Engine does not have any database. It uses the database defined in its parent app in which it is mounted. So obviously your db:migrate would not work.
Do the following in your parent app for an engine:
Mount your engine in the Gemfile of a rails application as just another engine using :path or :git option
gem 'engine_name', :path=>'path/to/engine/directory'
bundle install
rake engine_name:install:migrations
rake db:migrate
I've entered spec/dummy in my engine folder and just runned rake db:migrate plus the same for test Env, and db/schema.rb was added.
But I had to add spec/dummy/db folder manually before.

Rails - How can I run cucumber tests only?

I can run all models with rake:models
Any option to do that that for cucumber tests instead of just rake and running all tests at all levels?
I tried:
$ rake spec:cucumber
rake aborted!
Don't know how to build task 'spec:cucumber'
You should be able to just run rake cucumber
A quick output of rake -T shows:
rake cucumber # Alias for cucumber:ok
rake cucumber:all # Run all features
rake cucumber:ok # Run features that should pass
rake cucumber:rerun # Record failing features and run only them if any exist
rake cucumber:wip # Run features that are being worked on

How to build task 'gems:install'

I am deploying my rails app to a linux server and i have some of the rake tasks missing inlcuding rake gems:install and rake db
I am running rails 2.3.4 from GEM.
Why is this?
How do I fix this? can I update somehow?
they are missing from rake -T list
rake apache2 # Build Apache 2 module
rake clean # Remove compiled files
rake clobber # Remove all generated files
rake default # Build everything
rake doc # Generate all documentation
rake doxygen # Generate Doxygen C++ API documentation if ...
rake doxygen:clobber # Remove generated Doxygen C++ API documenta...
rake doxygen:force # Force generation of Doxygen C++ API docume...
rake fakeroot # Create a fakeroot, useful for building nat...
rake nginx # Build Nginx helper server
rake package # Build all the packages
rake package:clean # Remove package products
rake package:debian # Create a Debian package
rake package:force # Force a rebuild of the package files
rake package:gem # Build the gem file passenger-2.2.4.gem
rake rdoc # Build the rdoc HTML Files
rake rdoc:clobber # Remove rdoc products
rake rdoc:force # Force a rebuild of the RDOC files
rake sloccount # Run 'sloccount' to see how much code Passe...
rake test # Run all unit tests and integration tests
rake test:cxx # Run unit tests for the Apache 2 and Nginx ...
rake test:integration # Run all integration tests
rake test:integration:apache2 # Run Apache 2 integration tests
rake test:integration:nginx # Run Nginx integration tests
rake test:oxt # Run unit tests for the OXT library
rake test:rcov # Run coverage tests for the Ruby libraries
rake test:restart # Run the 'restart' integration test infinit...
rake test:ruby # Run unit tests for the Ruby libraries
my rake file contains this:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
How do I add the gems and db rake tasks? and why are they missing?
What is the output of rake -T? This should list all avaiable tasks. In a RoR application, the Rakefile defines your tasks.
You can update gems using gem update.
Check your Capfile, if you are in fact running the gems:install from Capistrano. Apparently, the way to do this is to ensure you're in the right directory internally when running Capistrano.
namespace :gems do
desc "Install gems"
task :install, :roles => :app do
run "cd #{current_path} && #{sudo} rake RAILS_ENV=production gems:install"
end
end
You could also always specify the Rakefile to be sure using the -f [FILE] option in front of the rake command.
You could try updating your Rails install, or reinstalling rails altogether by passing the --force flag. Do you have any other projects for which this command works? Check the rake files from those projects. It looks like your rakefile is the same as mine though... Is this project originally based on an older version of rails? What Gem version are you running? You might need to do a gem update --system. All these are possibilities.
I suppose you could always recreate your project. Annoying but always seems to help worst case scenario.
At least that'll give you an idea of whether or not it's the project or something in some kind of dependencies issue.
If you are using a rails app, you also have rake tasks defined in lib/tasks/SOME_TASK.rake
if you define the SOME_TASK it will then show up when you run rake -T and be an available command.

Resources