I try to execute a binary on heroku. I follow this blog : http://www.verrot.fr/2010/02/24/executing-binary-files-with-ruby-on-rails-and-heroku/ :
I have the following code :
#exec = IO.popen("#{Rails.root}/bin/aapt version")
#result = #exec.gets
puts #result
I've got the following error on heroku while it's working on local rails server :
command not found: app/bin/aapt version
Have you got any idea on a way to do that ? Or if you already done that ?
How I have gotten this to work, but be warned, Heroku does not support this solution. The direct quote from Heroku Support is "you are on your own."
Create a bin directory in your application.
Add Debian etch amd64 binaries to this directory. For example, add application called mongodump.
Have your code execute system call. Example (note the lack of path):
system "bin/mongodump --help"
A true or false will be returned from the system call.
Did you make sure the permissions on your local binary allow execution? Git is permissions-aware. If not, you need to make sure the file allows executable permissions (modify the permissions if you must), then add the modified file to git and repush to heroku before trying again. Keep in mind that the user heroku will use to execute the file may or may not be the owner, so you may need to play with them in order to get heroku to recognize it. Just chmod 777 bin/executable_name as a last resort.
Related
I was trying to hide my credentials before pushing the repository publicly, as I should.
For that, I've used this resource, which worked perfectly on development mode.
For short, I've assigned global variables inside a ".api_keys.rb" file, called them on the appropriate file (devise.rb on this case) and added it to .gitignore.
Then I pushed it to GitHub. Later on, I needed to clone this one last commit. But then when I try running it, it responds with "cannot load such file -- /path/.api_keys.rb".
What am I missing? I can provide any more details if needed. Thank you.
Adding a file to .gitignore means that the file is removed from the repository and only exists locally because the file is ignored by git completely.
Because it is not stored in your git repository anymore it is not available to remote servers or other developers when pulling the repository from GitHub.
To fix this your need to remove the file from .gitignore and push it again when it still exists on your machine or you need to recreate it.
Btw the way to store, for example, API keys securely in Rails is to use encrypted files. I suggested reading in the [Rails Guides about Environmental Security and Custom Credentials].(https://edgeguides.rubyonrails.org/security.html#environmental-security)
Im trying to migrate a db2 database to Ruby on Rails, but just when I run rails g scaffold, I get this:
Rails Error: Unable to access log file. Please ensure that /home/.../log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I have checked and my development.log does not exist! I'm not sure why, since I followed every step during the installation, but still my file doesn't exist. How can I create it? I have already tried uninstalling and installing Rails again, but the problem remains.
Maybe just do what it asks you to do?:
$ touch the_required_path/development.log
$ chmod 0666 the_required_path/development.log
I've always had success with the the log file permissions as 644. When this has happened to me, more than once I might add, it has always been answered by the question linked below. Since this is the first answer in Google for the query I use, I'm linking to the answer that I really want.
Rails: Unable to access log file
I am having a problem with the ExecJS in that it is unable to locate a required Runtime. I am using Windows, and I have both Windows CScript and Node.js installed on my computer, but neither of these guys are being invoked.
As a result, I am unable to run any rails task that involves this (I cannot even load my rake list in RubyMine to call actions such as db:create to create my databases from a fresh project.)
I am capable of accessing both csript and node from the command line, and I have checked my environment variables and their proper file locations are in the PATH. There's something else ruining my ability to use ExecJS. Has anyone else had a similar experience where you have had all of the right stuff, but something is still going wrong?
When Ruby spawns child process to invoke CScript or Node, it will use the same rules that allow cmd.exe execute them from the command line.
But, sometimes, stuff in your registry or your environment variables can affect this process.
At RubyInstaller project we collected a series of troubleshooting items that could possible be the culprit.
Please check that COMSPEC environment variable is set to use cmd.exe and nothing like TCC/LE or other stuff.
C:\>SET COMSPEC
Also, check that your registry do not contain an AutoRun key, which will also affect Ruby.
C:\>REG QUERY "HKCU\Software\Microsoft\Command Processor"
C:\>REG QUERY "HKLM\Software\Microsoft\Command Processor"
If you see a key AutoRun in one of the above commands, that means something is setup to automatically execute everytime a new cmd.exe is started, which is bad for some cases.
Please follow the instructions in the Troubleshooting page on how to remove it.
This also affects gem installation that requires compilation, but if is not failing for you then the problem might be something else.
Hope that helps.
I was having similar problems, my basic skeleton app wouldn't run despite having Node.js installed, and then trying therubyracer gem. Finally I decided to use my troubleshooting mantra with windows, "When in doubt, run as admin". So I ran my rails cmd as an admin and it worked fine after that.
I am setting up Rails+ffmpeg on Ubuntu and I keep getting
Errno::ENOENT
No such file or directory..
The setup is as follows:
/home/username/RailsApp
/home/username/videos/
I am trying to run ffmpeg to write to /home/username/videos and I used "/home/username/videos/" and "~/videos/" but no luck..
What am I missing?
"www-data" user is included in "username" group..
Rails app works fine otherwise..
Any input greatly appreciated!
Thanks!
Generally is good not to be dependent on local file system. Try following:
path_to_video = "#{Rails.root.to_s}/videos/video1.avi"
print File.exist?(path_to_video)
If you don't want to have videos in Rails/public just create a link with ln -s target link_name and on production server you should do it in similar way e.g. with capistrano.
Btw. what are the rights to videos? -rw-r--r--? and under wich user is running your webserver?
I am attempting to take a whack at creating my first Rails application template and I am running into a slight issue with the copy_file method.
First some background.... Apparently the Ruby OpenSSL package does not ship with a CA store, so any attempt to connect to an HTTPS service will fail out of the box. The way around this(for Rails 3 apps) is to add the line OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE to the top of your config/environment.rb file. I need to do this on the fly in my template so I can install jQuery.
So I have that all figured out, my general thought is to:
Make a backup of my config/environment.rb file.
Prepend the data to original
Run the jquery:install --ui task
Restore the original config/environment.rb file.
See my template Gist, Lines 25..34 is the relevant section.
So all of that works until step #4 which fails with Error: Could not find "env.orig" in any of your source paths on line #31.
This is VERY perplexing to me because line #28 works, I can see the env.orig file on disk, so why won't the reverse work?
What am I doing wrong?
Update 1:
After looking at the Thor source thor\actions.rb it became clear that Thor uses different paths (not your current project path) for the source and destination. Furthermore my copy was actually not working, it was actually coping the ERB template file, not the already generated file.
After a breather it occurred to me use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that. Does anyone have a better way?
See my Update for a Why, but the solution was to use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that.