I'm trying to automate a ruby app deployment on a Windows machine with a batch script.
Everything is going dandy, except for the following line:
gem install bundler
If I type this in manually, all goes well. If I use a batch script, however, the process is killed as soon as the installation completes. This is what I'm using:
pause
gem install bundler --no-ri --no-rdoc
pause
I've tried with the -f switch and also all docs; nothing seems to prevent the window from getting killed. I need the process to stay alive so I can bundle install. Any idea why this is happening, and how I can keep it alive post-install?
gem is a batch file (gem.bat). When you're invoking a batch file from another one, it is transferring control to it and not resuming.
You should try using CALL instead:
CALL a second batch file
The CALL command will launch a new batch file context along with any specified arguments.
When the end of the second batch file is reached (or if EXIT is used), control will return
to just after the initial CALL statement.
Documentation here:
http://ss64.com/nt/call.html
You can also avoid the batch file by doing ruby -S gem ... which is more verbose and will work since there is a gem (extensionless) file along gem.bat.
Hope that helps.
Related
I am working on migrating JHipster to Yeoman 0.20.1, in order to prepare for Yeoman 1.0.
At the end of our process, we normally:
Run npm install and bower install
Use a callback function to run some Grunt or Gulp.js task, usually grunt wiredep
This has always worked, and here is the current code that runs the installation process.
Since I migrated to Yeoman 0.20.1, we still have:
The installDependencies function being called
It even prints out the message I'm all done. Running npm install & bower install for you to install the required dependencies. If this fails, try running the command yourself.
But in fact no installation happens! NPM and Bower do not install anything, and our Grunt task is not called. Note that if I call them manually, they work correctly.
If tried to debug this, and it looks like this method is not being called.
Can anybody help me on this issue?
I feel like the run loop might be done after the end event is triggered. installDependencies schedule install methods to be runned during the install priority. If the run loop is done, they won't run.
You should be able to just call installDependencies at any time and not worry about the end event callback. If you want to imitate the behavior you currently have, then call installDependencies inside a method called end.
As a side note on the installDependencies API, you don't need to manually specify skipInstall anymore (that's now automatic).
I have a ruby script open.rb
require 'launchy'
Launchy.open("http://stackoverflow.com")
Now what i want is that in a day i run script first time than it should run after every 10 minute.
so is there any way to do this and here i am using windows 7.
After google on this i got a way to do it Ruby on Rails with worker as a background job but that is not my solution so is there any possible way to do it or is there any gem to do this task.
and also how can i clear chache before running this.
The solution is to use Windows Scheduler.
To set the task run every 10 minutes, follow the solution in this Stack Overflow question: windows scheduler to run a task every x-minutes?
UPDATE: here is a way to run associate Ruby script to ruby.exe : https://stackoverflow.com/a/1422398/188331 ( you can make a batch script )
Does anyone know of any tools to monitor and alert me when new versions of gems named in my Gemfile are released?
It could be as simple as a rake task that reports my current version and the latest version, or as fancy as a background process that logs messages to the console whenever new versions are available.
Bundler 1.1 introduced the command
bundle outdated
But, as you mentioned, for those with v 1.0, the bundle-outdated gem exists.
I'm using this site: bundle watcher
You just upload your gem file or link to it, and then you are notified via RSS when an update is available.
I had the exact same need but not only for bundler, also for npm and pacman (archlinux pacman manager) checkzilla.
It's extensible so there's also different notifiers (console, email, twitter,..). It's beta software as of now but I'm using it on my servr and it's working quite well.
I am also using bundle watcher, but I've set up an If This Than That sequence to email me whenever there is an update. This way I get a proactive notification.
There is also a commercial site called Gemnasium, but I have not used it.
This is exactly what Gemnasium is doing
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 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.