Errno::ENOEXEC exception - ruby-on-rails

I am working on the 2.0.2 rails application. Now when I execute the command from a windows pc with rake db:migate it gives Errno::ENOEXEC in SystemsController#index.
Is there any other way to execute the system commands from the rails application on windows pc?
Here is the error:
Errno::ENOEXEC in SystemsController#index
Exec format error - rake db:migrate
RAILS_ROOT: E:/RoR/ibt/InstantRails-2.0-win/rails_apps/config
Application Trace | Framework Trace | Full Trace
E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``' ``
E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'`
app/controllers/systems_controller.rb:24:in `index'
I am getting on ruby console:
irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1
Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config
11/29/2012 03:11 PM <DIR> .
11/29/2012 03:11 PM <DIR> ..
11/29/2012 02:41 PM <DIR> app
11/29/2012 02:42 PM <DIR> config
=> true
irb(main):002:0> system('rake db:migrate')
=> false
irb(main):003:0>

I have solved this issue by running the rake file from the the batch file where the rake is situated.
irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1
Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config
11/29/2012 03:11 PM <DIR> .
11/29/2012 03:11 PM <DIR> ..
11/29/2012 02:41 PM <DIR> app
11/29/2012 02:42 PM <DIR> config
=> true
irb(main):002:0> system('rake db:migrate')
=> false
In the controller file
system("#{RAILS_ROOT}/../../ruby/bin/rake.bat db:migrate")
Gives result
== 99 AddFieldtoSystemAssoziations: migrating =================================
== 99 AddFieldtoSystemAssoziations: migrated (0.0391s) ========================

Related

Gluon Mobile not compiling on WSL2 Ubuntu 20.04

Ive been trying to create an apk file for my gluon project. On windows and for windows, the prroject runs perfectly but when in Ubuntu, the commands mvn -Pandroid gluonfx:runagent will run the project but the project wont compile and build.
the error I get keep getting is:
[Wed Jan 04 15:32:35 IST 2023][INFO] We will now compile your code for aarch64-linux-android. This may take some time.[Wed Jan 04 15:33:01 IST 2023][INFO] Additional information: Objectfile should be called com.gluonapplication.mobiletrial1.o but we didn't find that under /mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm[Wed Jan 04 15:33:01 IST 2023][SEVERE] Compiling failed.Check the log files under /mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/logAnd please check https://docs.gluonhq.com/ for more information.[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 45.283 s[INFO] Finished at: 2023-01-04T15:33:01+05:30[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.15:compile (default-cli) on project mobiletrial1: Compiling failed -> [Help 1]
The log file
[Wed Jan 04 16:48:54 IST 2023][FINE] PB Command for compile: /mnt/c/Java/linux/graalvm-svm-java17-linux-gluon-22.1.0.1-Final/bin/native-image -Djdk.internal.lambda.eagerlyInitialize=false --no-server -H:+SharedLibrary -H:+AddAllCharsets -H:+ReportExceptionStackTraces -H:-DeadlockWatchdogExitOnTimeout -H:DeadlockWatchdogInterval=0 -H:+RemoveSaturatedTypeFlows -H:+ExitAfterRelocatableImageWrite --features=org.graalvm.home.HomeFinderFeature -H:TempDirectory=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/tmp -H:EnableURLProtocols=http,https --initialize-at-build-time=com.gluonhq.charm.glisten.visual.MaterialDesignIcon -H:ReflectionConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/reflectionconfig-aarch64-android.json -H:JNIConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/jniconfig-aarch64-android.json -H:ResourceConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/resourceconfig-aarch64-android.json -H:-SpawnIsolates -Dsvm.targetArch=aarch64 -H:+ForceNoROSectionRelocations --libc=bionic -H:+UseCAPCache -H:CAPCacheDir=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/capcache -H:CompilerBackend=lir -H:IncludeResourceBundles=com/sun/javafx/scene/control/skin/resources/controls,com/sun/javafx/scene/control/skin/resources/controls-nt,com.sun.javafx.tk.quantum.QuantumMessagesBundle -Dsvm.platform=org.graalvm.nativeimage.Platform$LINUX_AARCH64 -cp /home/vatsal/.m2/repository/com/gluonhq/substrate/0.0.55/substrate-0.0.55.jar:/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/tmp/classpathJar.jar com.gluonapplication.MobileTrial1
[Wed Jan 04 16:48:54 IST 2023][FINE] Start process compile...
[Wed Jan 04 16:48:54 IST 2023][FINE] Result for compile: 0
[Wed Jan 04 16:48:54 IST 2023][FINE] Logging process [compile] to file: /mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/log/process-compile-1672831134641.log
[Wed Jan 04 16:48:54 IST 2023][INFO] Additional information: Objectfile should be called com.gluonapplication.mobiletrial1.o but we didn't find that under /mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm
[Wed Jan 04 16:48:54 IST 2023][SEVERE] Compiling failed.
Check the log files under /mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
gluonfx log file
Process
=======
compile
Command Line
============
/mnt/c/Java/linux/graalvm-svm-java17-linux-gluon-22.1.0.1-Final/bin/native-image -Djdk.internal.lambda.eagerlyInitialize=false --no-server -H:+SharedLibrary -H:+AddAllCharsets -H:+ReportExceptionStackTraces -H:-DeadlockWatchdogExitOnTimeout -H:DeadlockWatchdogInterval=0 -H:+RemoveSaturatedTypeFlows -H:+ExitAfterRelocatableImageWrite --features=org.graalvm.home.HomeFinderFeature --features=com.gluonhq.substrate.feature.GluonFeature -H:TempDirectory=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/x86_64-linux/gvm/tmp -H:EnableURLProtocols=http,https -H:ReflectionConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/x86_64-linux/gvm/reflectionconfig-x86_64-linux.json -H:JNIConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/x86_64-linux/gvm/jniconfig-x86_64-linux.json -H:ResourceConfigurationFiles=/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/x86_64-linux/gvm/resourceconfig-x86_64-linux.json -H:IncludeResourceBundles=com/sun/javafx/scene/control/skin/resources/controls,com/sun/javafx/scene/control/skin/resources/controls-nt,com.sun.javafx.tk.quantum.QuantumMessagesBundle -Dsvm.platform=org.graalvm.nativeimage.Platform$LINUX_AMD64 -cp /home/vatsal/.m2/repository/com/gluonhq/substrate/0.0.55/substrate-0.0.55.jar:/mnt/g/Intellij_Projects/MobileTrial1/target/gluonfx/x86_64-linux/gvm/tmp/classpathJar.jar com.gluonapplication.MobileTrial1
Output
======
Result
======
result: 0
I have tried uninstalling and reinstalling ubuntu and wsl and I have tried the same process on Linux and have got the same error.

How to start a rails task as a service

I have a TCP server written in the rails application as a rails task.
However it can be started from as:
rails socketing:start
and the process will start executing if wanted it to be a task that keep on running in the beckground them change it as:
nohup rails socketing:start &
and will be keep on working in backgroup as the tcp server has multi threading implemented into it if there is an error that will stop only 1 thread.
Now I would like this process to be started by the service at the boottime of the ubuntu server for that created a service and enabled it.
But the code break
can you please suggest a way out
My service is written as:
[Unit]
Description = TCP at 51234
After = network.target
[Service]
Environment="HOME=/home/vidur"
ExecStart = /home/vidur/rails_app/tukaweb/custom_script.sh
[Install]
WantedBy = multi-user.target
My custom_script.sh as:
#!/bin/bash
cd /home/vidur/rails_app/project_dir
/home/vidur/.rbenv/shims/bundler exec rake rails socketing:start
Start the service as:
sudo systemctl start socketing.service
It give o/p as:
Jun 10 17:45:31 Vidur-PC systemd[1]: Started TCP at 51234.
Jun 10 17:45:31 Vidur-PC systemd[1]: socketing.service: Succeeded.
But did not start the rails task or even recognise rails environment:
I have rails task as:
task start: :environment do
require 'socket'
puts "Started TCP Server at PORT 53492"
server = TCPServer.new 51324 # Server bound to port 51234
loop do
Thread.start(server.accept) do |client|
client.close
end
end
p "result = #{result}"
p 'Bye'
end
This code gives following error:
Jun 10 19:16:40 Vidur-PC systemd[1]: Started TCP at 53492.
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: rake aborted!
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: ArgumentError: couldn't find login name -- expanding `~'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: /home/vidur/rails_app/tukaweb/config/application.rb:8:in `<top (required)>'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: /home/vidur/rails_app/tukaweb/Rakefile:4:in `require_relative'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: /home/vidur/rails_app/tukaweb/Rakefile:4:in `<top (required)>'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: /home/vidur/.rbenv/versions/2.7.2/bin/bundler:23:in `load'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: /home/vidur/.rbenv/versions/2.7.2/bin/bundler:23:in `<main>'
Jun 10 19:16:43 Vidur-PC custom_script.sh[60012]: (See full trace by running task with --trace)
Jun 10 19:16:44 Vidur-PC systemd[1]: socketing.service: Main process exited, code=exited, status=1/FAILURE
Jun 10 19:16:44 Vidur-PC systemd[1]: socketing.service: Failed with result 'exit-code'.
updated application.rb file:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module TukaWeb
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
if Rails.env.development?
config.active_job.queue_adapter = :async
else
config.active_job.queue_adapter = :sidekiq
end
config.generators.javascript_engine = :js
config.action_dispatch.default_headers = {
'Access-Control-Allow-Origin' => 'https://tukadata.tukatech.com',
'Access-Control-Request-Method' => %w{GET POST OPTIONS}.join(",")
}
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
end
It stated the tcp process rake task but for the root user only.
DB Error left:
`connect': Access denied for user 'root'#'localhost'
but if run the process normal then it run.
issue was with puma he need home so updated service as:
[Unit]
Description = TCP at 51234
After = network.target
[Service]
Environment="HOME=/home/vidur"
ExecStart = /home/vidur/rails_app/tukaweb/custom_script.sh
[Install]
WantedBy = multi-user.target

I need to know how to write my manifest.json file to deploy my application on oracle

Initialized application creation...
Acquired resources for instance(2G) web.1...
Acquired resources for instance(2G) web.2...
Failed to deploy application(v1) for instance(2G) web.1...
Application is not running. Following are application logs 2018-03-29T00:59:27.429357+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas 46 Mar 29 00:58 .....
2018-03-29T00:59:27.430904+00:00 ACCS[web.1]: Starting application with launch command [ ruby app.rb ]
2018-03-29T00:59:27.466311+00:00 APP[web.1]: ruby: No such file or directory -- app.rb (LoadError)
2018-03-29T00:59:40.674751+00:00 ACCS[web.1]: "Content of APP_HOME [ /u01/app ] dir "
2018-03-29T00:59:40.676669+00:00 ACCS[web.1]: total 0
2018-03-29T00:59:40.676752+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas 192 Mar 28 02:31 bitview
2018-03-29T00:59:40.676804+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas 14 Mar 29 00:58 .
2018-03-29T00:59:40.676878+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas 46 Mar 29 00:58 ..
2018-03-29T00:59:40.678051+00:00 ACCS[web.1]: Starting application with launch command [ ruby app.rb ]
2018-03-29T00:59:40.713732+00:00 APP[web.1]: ruby: No such file or directory -- app.rb (LoadError)
Log-URL: [https://gse00014896.us.storage.oraclecloud.com/v1/Storage-gse00014896/_apaas/testrun/logsV2/4157996400_web.1_538e60cd_2018-03-29-010000_cust_server.out.zip]
App Summary - Name:[testrun], Identity domain: [idcs-f2b25b3358db4bd7a23ab81ff93845e1], Service Entitlement:[595583085], Compute Site:[US006_Z55]
For the complete application log, refer to log URL
Failed to deploy application(v1) for instance(2G) web.2...
Application is not running. Following are application logs 2018-03-29T00:59:26.758054+00:00 ACCS[web.2]: drwxr-xr-x 1 apaas apaas 46 Mar 29 00:58 .....
2018-03-29T00:59:26.759390+00:00 ACCS[web.2]: Starting application with launch command [ ruby app.rb ]
2018-03-29T00:59:26.794616+00:00 APP[web.2]: ruby: No such file or directory -- app.rb (LoadError)
2018-03-29T00:59:39.974943+00:00 ACCS[web.2]: "Content of APP_HOME [ /u01/app ] dir "
2018-03-29T00:59:39.977470+00:00 ACCS[web.2]: total 0
2018-03-29T00:59:39.977618+00:00 ACCS[web.2]: drwxr-xr-x 1 apaas apaas 192 Mar 28 02:31 bitview
2018-03-29T00:59:39.977749+00:00 ACCS[web.2]: drwxr-xr-x 1 apaas apaas 14 Mar 29 00:58 .
2018-03-29T00:59:39.977890+00:00 ACCS[web.2]: drwxr-xr-x 1 apaas apaas 46 Mar 29 00:58 ..
2018-03-29T00:59:39.979596+00:00 ACCS[web.2]: Starting application with launch command [ ruby app.rb ]
2018-03-29T00:59:40.015352+00:00 APP[web.2]: ruby: No such file or directory -- app.rb (LoadError)
App Summary - Name:[testrun], Identity domain: [idcs-f2b25b3358db4bd7a23ab81ff93845e1], Service Entitlement:[595583085], Compute Site:[US006_Z55]
For the complete application log, refer to log URL
Log-URL: [https://gse00014896.us.storage.oraclecloud.com/v1/Storage-gse00014896/_apaas/testrun/logsV2/4157996401_web.2_b475cb31_2018-03-29-005959_cust_server.out.zip]
Failed to create application...
For a basic app you don't need much, there's an example here
http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/ruby/ruby-getting-started/ruby-getting-started.html
{
"runtime":{
"majorVersion":"2.4.1"
},
"command": "ruby app.rb",
"release": {},
"notes": "Ruby Hello World"
}
substitute app.rb with whatever the name of your main file is.
What you can do if you need to install gems or something is call a shell script instead with sh start.sh and (in the same directory) have a shell file like so
#!/bin/env sh
gem install rails
ruby app.rb
I hope this helps! :smiley:

Two Rails servers with the same Time.zone, same server timezone, but getting different results from Date.to_time

I am running Rails on two machines, but getting different results from to_time method. I only checked the system timezone and Time.zone configuration, am I missing anything? Thanks
Server 1
user#Server1:/var/www/app$ date
Wed Oct 23 23:56:35 MDT 2013
user#Server1:/var/www/app$ cat /etc/timezone
America/Denver
user#Server1:/var/www/app$ bundle exec rails c production
irb(main):011:0> Time.zone
=> (GMT+00:00) UTC
irb(main):012:0> Date.parse("10/24/2013").to_time
=> 2013-10-24 00:00:00 +0000
Server 2
user#Server2:/var/www/app$ date
Thu Oct 24 00:03:28 MDT 2013
user#Server2:/var/www/app$ cat /etc/timezone
America/Denver
user#Server2:/var/www/app$ bundle exec rails c production
irb(main):002:0> Time.zone
=> (GMT+00:00) UTC
irb(main):003:0> Date.parse("10/24/2013").to_time
=> 2013-10-24 00:00:00 -0600
Time#local_time (called by ActiveSupport in the implementation of Date#to_time) respects the TZ environment variable for which timezone should be used for the "local" time.
Ensure that the environment is the same between the two servers.

package my first Blackberry widget. - xml file not found

I am trying to package my first Blackberry widget. as described on Blackberry site:
http://docs.blackberry.com/en/developers/deliverables/10593/BlackBerry_widget_samples_Hello_world.pdf
I edited files in Eclipse and an trying to create a .cod file with command line packaging tool.
Contents of zip files include config.xml
Directory of C:\trash\hello
12/13/2010 03:11 PM <DIR> .
12/13/2010 03:11 PM <DIR> ..
09/29/2009 02:09 PM 544 config.xml
12/13/2010 03:11 PM 0 file.txt
09/29/2009 02:31 PM 648 index.html
12/13/2010 02:32 PM <DIR> Scripts
12/13/2010 02:32 PM <DIR> Styles
3 File(s) 1,192 bytes
Directory of C:\trash\hello\Scripts
12/13/2010 02:32 PM <DIR> .
12/13/2010 02:32 PM <DIR> ..
09/29/2009 02:32 PM 172 action.js
1 File(s) 172 bytes
Directory of C:\trash\hello\Styles
12/13/2010 02:32 PM <DIR> .
12/13/2010 02:32 PM <DIR> ..
09/29/2009 02:15 PM 14 simple.css
1 File(s) 14 bytes
However widget packeger cannot find config.xml file.
C:\Research In Motion\BlackBerry Widget Packager>bbwp c:\trash\trash\hello.zip
[INFO] Parsing command line options
[INFO] Parsing bbwp.properties
[INFO] Validating widget archive
[ERROR] Invalid widget archive - failed to find config.xml

Resources