Already initialized constant APP PATH rails - ruby

I got this error just after installing devise 3.4.0 gem in my application. When I input rails s in terminal, I get the error below..
[kmartin#localhost register]$ rails s
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
bin/rails:6: warning: already initialized constant APP_PATH
/home/kmartin/work/register/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.

I actually just changed my devise gem from 3.1. to just gem 'devise' then bundle installed and my problem was solved...It seems the version of devise wasnt supported by rails 4.

Related

Ruby on Rail running apache show index of when accessing the site

I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320

Problems with ruby-appium-cucumber on AWS Device Farm

I'm trying to run my test suite on AWS device farm using a custom environment. The test suite runs fine locally but when I run it on device farm some tests fail randomly, and some other acts as expected. Sometimes it looks like it's skipping the cucumber hooks, or just not running the steps.
Here is my custom environment configuration:
# Phases are collection of commands that get executed on Device Farm.
phases:
# The install phase includes commands that install dependencies that your tests use.
# Default dependencies for testing frameworks supported on Device Farm are already installed.
install:
commands:
# By default the ruby version installed is 2.5.1
- mkdir /tmp/tempdir
- export TMPDIR="/tmp/tempdir"
- export TMP="/tmp/tempdir"
- export TEMP="/tmp/tempdir"
- rvm install "ruby-2.6.5"
- rvm use 2.6.5
# you can switch to an alternate ruby version using below command.
#- rvm install 2.3.1 --autolibs=0
# Unpackage and install the gems
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
# Use a pre-configured ruby environment to run your tests.
# This environment has the following gems pre-installed (appium_lib (9.16.1), test-unit (3.2.9)) along with their dependencies.
# If you are using this env, please make sure you do not upload the Gemfile.lock while packaging your tests.
# If the Gemfile.lock contains different versions for the already installed packages, it will ignore the pre-installed packages.
# Using this env can help you speed up your test set up phase as you wont have to install all the gems.
# This default env is only available for ruby 2.5.3.
- rvm gemset use default-ruby-gemset-env-version-1 --create
# Alternatively, you can create a new virtual ruby env using the command:
#- rvm gemset use env --create
# Install the gems from the local vendor/cache directory
- gem install bundler --no-document
- bundle config set path 'vendor/cache'
- gem update --system
- bundle install
# This test execution environment uses Appium version 1.9.1 by default, however we enable you to change it using the Appium version manager (avm). An
# example "avm" command below changes the version to 1.14.2.
# For your convenience, we have preinstalled the following versions: 1.9.1, 1.10.1, 1.11.1, 1.12.1, 1.13.0, 1.14.1, 1.14.2, 1.15.1 or 1.16.0.
# To use one of these Appium versions, change the version number in the "avm" command below to your desired version:
- ln -s /usr/local/avm/versions/1.9.1/node_modules/.bin/appium /usr/local/avm/versions/1.9.1/node_modules/appium/bin/appium.js
# The pre-test phase includes commands that setup your test environment.
pre_test:
commands:
# We recommend starting appium server process in the background using the command below.
# Appium server log will go to $DEVICEFARM_LOG_DIR directory.
# The environment variables below will be auto-populated during run time.
- echo "Start appium server"
- >-
appium --log-timestamp
--default-capabilities "{\"deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \"platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\",
\"app\":\"$DEVICEFARM_APP_PATH\", \"udid\":\"$DEVICEFARM_DEVICE_UDID\", \"platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\",
\"chromedriverExecutable\":\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\"}"
>> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &
- >-
start_appium_timeout=0;
while [ true ];
do
if [ $start_appium_timeout -gt 60 ];
then
echo "appium server never started in 60 seconds. Exiting";
exit 1;
fi;
grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
if [ $? -eq 0 ];
then
echo "Appium REST http interface listener started on 0.0.0.0:4723";
break;
else
echo "Waiting for appium server to start. Sleeping for 1 second";
sleep 1;
start_appium_timeout=$((start_appium_timeout+1));
fi;
done;
# The test phase includes commands that start your test suite execution.
test:
commands:
# Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path.
- echo "Navigate to test source code"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- echo "Start Appium Ruby test"
# Modify/Enter the command below to start the tests. The comamnd should be similar to what you use to run the tests locally.
# "bundle exec" is a Bundle command to execute a script in the context of the current bundle.
# For e.g. assuming you run your tests locally using command "ruby YOUR_TEST_FILENAME.rb.", to run your ruby tests using bundle exec command you can use:
- bundle exec rake set_environment[amazon]
- bundle exec rake test
# The post test phase includes are commands that are run after your tests are executed.
post_test:
commands:
# The artifacts phase lets you specify the location where your tests logs, device logs will be stored.
# And also let you specify the location of your test logs and artifacts which you want to be collected by Device Farm.
# These logs and artifacts will be available through ListArtifacts API in Device Farm.
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_LOG_DIR
Here are the cucumber logs(I have tried to use backtrace to get more info but for some reason is not working in AWS)
Start Appium Ruby test
[DeviceFarm] bundle exec rake set_environment[amazon]
[DeviceFarm] bundle exec rake test
Using the test, no_bugs and pretty_progress profiles...
F------
Failing Scenarios:
cucumber -p test -p no_bugs -p pretty_progress features/regression/android/games/lightning.feature:45 # Scenario: Top up modal appears for a user without funds on lightning flow purchase attempts on all or nothing
1 scenario (1 failed)
6 steps (6 skipped)
1m1.742s
Cucumbers failed
I discovered that my capabilities for appium weren't correct and they lacked some capabilities, without them appium and cucumber acts up weirdly, here are the capabilities I used:
caps = {
"automationName": "UiAutomator2",
"platformName": ENV['DEVICEFARM_DEVICE_PLATFORM_NAME'],
"deviceName": ENV['DEVICEFARM_DEVICE_NAME'],
"app": ENV['DEVICEFARM_APP_PATH'],
"uuid": ENV['DEVICEFARM_DEVICE_UDID'],
"appPackage": "appPackageOfYourChoice",
"appActivity": "appActivityOfYourChoice",
"autoGrantPermissions": true
}

When running an application under ruby 2.3.1 using the rails server command, the following error occurs: can not modify a frozen array (RuntimeError)

I have to run an application developed in Ruby on rails. ruby 2.3.1 and rails 4.2.0
When I execute the rails server command. I get the following error:
.... config / initializers / doorkeeper.rb: 75: in <top (required)>: can not modify a frozen array (RuntimeError).
Can I explain how to succeed to no longer have this error, thank you
Info :
The "bundle install" command runs successfully.
The code around doorkeepee.rb near line 75 : Doorkeeper.configuration.token_grant_types << "password"
I'm trying to understand how RAIL_ENV works. Can you help me at the same time?

Grape stand alone rest api ERROR: No application configured, nothing to run

I have followed this tutorial step by step: https://wildandcrazytutorials.wordpress.com/2016/03/05/how-to-build-a-grape-standalone-rest-api/
However I get the error:
Puma starting in single mode...
Version 3.6.2 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
Min threads: 0, max threads: 16
Environment: development
ERROR: No application configured, nothing to run
when I run puma in In ./myapp
I am running it on a MacOs.
I am new to grape and I would love some guidance. I have literally simply followed the tutorial up to "Run the following to startup the server after every changeā€¦
In ./myapp
$ puma"
I got my answer from Daniel # https://groups.google.com/forum/#!forum/ruby-grape
There was a syntax error, his code below fixed my problem, I appreciate it.
require 'rubygems'
require 'grape'
Dir.glob("**/*.rb").each do |f|
puts "Loaded #{f}"
require_relative "../#{f}" unless File.absolute_path(f) == __FILE__
end

delayed_job gem - NotImplementedError: fork is not available on this platform

I am using jruby (1.7.3 or 1.7.9), delayed_job (1.8.4), daemons (1.1.9) gems for my rails 2.3.17 application.
I am trying to start the delayed job server using command:
1. jruby script/delayed_job start
Error:
RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
each_object at org/jruby/RubyObjectSpace.java:173
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:39
(root) at script/delayed_job:5
To resolve this error, I passed "-X+O" option & ran following command:
jruby -X+O script/delayed_job start
This has resolved "ObjectSpace is disabled" error but I am getting following error on local.
Error:
NotImplementedError: fork is not available on this platform
fork at org/jruby/RubyKernel.java:1880
safefork at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:11
call_as_daemon at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:43
start_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:259
start at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:296
run at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/controller.rb:70
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:197
call at org/jruby/RubyProc.java:290
call at org/jruby/RubyProc.java:224
catch_exceptions at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:196
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:45
times at org/jruby/RubyFixnum.java:280
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:43
(root) at script/delayed_job:5
Anyone can help me to resolve this error.
Locally I am able to start my server using "jrake jobs:work" command but I am not whether I can use "jrake jobs:work" instead of "jruby script/delayed_job start".
Thanks.
You cannot use delayed_job on jruby because it relies on Fork which is not available in jruby.

Resources