I'm running a Ruby file on Windows 8.
My computer doesn't know which program to run my Ruby file with. I have Ruby installed, but it won't let me open it without an IDE. My team members run it regularly from the command prompt and don't want us using IDEs.
Any thoughts on how to get it to run? Or should I ask my team members?
Ruby files aren't really "opened" as much as executed. Basically, the workflow is not to double click on a .rb file but rather to run it in the command line. Let's say you have a file called
hello.rb
To run this file you'd do:
$ ruby hello.rb
Now, as far as being sure you have ruby installed. Make sure that when you type
$ ruby --version
You get back a version number. Otherwise, it may not be installed. If that's the case, take a look here: http://rubyinstaller.org/
Also, if you want to edit a ruby file I'd recommend you use a text editor. On windows even notepad will do. Just right click on the file and select "Open with notepad" (I think). I've heard good things about http://notepad-plus-plus.org/
Please note, I haven't used Windows in years so I may be a tad off on some points.
Related
I have a bash script that works at the moment. It gets an image and JDK 8 from a link and then runs a installer for the JDK 8 to move on to setting up another piece of software.
As I was debugging the script, I kept finding myself having to delete directories and even the java installation because when I introduce a fix and rerun the script, I have to wait for everything to download again and I have to worry about duplicate files messing up my current logic -which can probably be improved, but I'll go to the StackExchange Code Review site later.
At the moment, I would like to know what approaches there are to prevent commands -like downloading the JDK and running the JDK installer script all over again and others- from running again.
What kind of general approaches are out there for cases such as these?
For the JDK download and running the installer, I did think of simply checking for the existing of java on the system and if there is then bash would not not to run those commands.
However, there are other commands I do not want run and I do want to simply check, for example, the existence of certain files to prevent wget-ing them all over again and moving them -causing duplicates. (Should I maybe suck it up and do that anyway as that might be best practice?)
I did also think of perhaps, at each successful command, outputting like a 1 to a text file and mapping each line in that text file to the commands run in the script (like using an if statement to see if that command had a 1 or not in the text file) and if it was a 0, then the script would know only to run that command and never the 1s.
That sounded clunky to me and I am pretty sure that is not a good approach.
Morning guys,
I am writing a small Ruby CLI app for myself, and I have run into a small issue that I hope you guys can help with. Apologies if this is a stupid question, I am very new to Ruby.
I am using https://github.com/davetron5000/gli as a foundation to build my my app since they make it easy to have all my commands and whatnot.
Question is, while I develop the app, I can run it using bundle exec bin/konstruct, but that only works from the folder where the code lies.
I want to run the app from a test folder so I can see whether the code I'm adding is doing what it should (make files, remove files, see if directory is empty, etc).
When I played around with NodeJS, I could link the app, and it would work anywhere. Is there something like that for Ruby apps that are still in development?
Two simple way:
1. Make bin/konstruct executable. So you can run it without bundle exec. Then link it in any directory in your $PATH with ln -s. (For Unix based systems)
2. Create a alias in your shell. something like this:
alias konstruct="bundle exec /FULL/PATH/TO/bin/konstruct"
(Also for Unix based systems)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This isn't so much a "question" as a methodology I found which I believe is working.
Most servers use the path "/usr/bin/perl" ... but Strawberry Perl (strawberryperl.com) use their own unique path of "/strawberry/perl/bin" (!!) (I tried installing into a different directory as allowed by the prompt, but it wouldn't work at all then! I read somewhere that some files within the installation are 'hardcoded' to the above path.)
I am not looking forward to having to rename all the shebangs of around 400 offline files, and then having to change them all again when uploaded, and I sought another solution. I found it in something called a "symbolic link".
Basically, it's an internal Windows redirect. It basically says "If you see the path as 'usr/bin/perl' then instead go to 'strawberry/perl/bin' " There are two ways to set this up.
The first is to open up a command line terminal ("CMD" in Windows search box, then click "cmd.exe") You use "cd.." to get back to the "C:>" prompt, and then enter "/d usr\bin\perl starwberry\perl\bin\perl.exe" and click enter. This will set up the <==> symbolic link. (Note directions of the slashes) That's OK for a one time use. (It may work without adding ".exe", but to be sure...)
But I design websites offline, so I need the redirect to be set up each time I boot up. You can do this as well with a batch file.
Using a text file, enter the same data as you did at the prompt, and save it as a ".bat" file to your startup folder, (as found in the left menu when clicking "Start" button lower left) You may well find other icons for programs that also initiate at startup within this folder.
I'm 99% certain this is working, because I went into the 'usr/bin/perl' and renamed the executable files as 'perl_old.exe' and 'perl_5.12.4_old.exe" and "wperl_old.exe" (so that if a Perl script DID access "usr\bin\perl" it wouldn't find any program to run) ... and the file still ran when I put URL into the browser.
So why the switch from ActiveState? I wanted to install a particular library. I tried it via PPM and was told I didn't have authorisation. No, this isn't an "Administrator Rights" issue of Windows; it's the fact that ActiveState now want to charge $999 for access to certain files. "Well, you can still use 'dmake' to create the files downloaded direct from CPAN" Er, no, you can't ... because "dmake" is one of the files under lock and key! And without that, you cannot install ANY file from CPAN. (The term "Holding You To Ransom" springs to mind.)
Using Strawberry Perl, it's just a case of starting a command line terminal, (CMD) moving back to the root (C:>) and typing "cpan". You now type "install MODULE::name". Boom! All the files for that particular module are downloaded and installed using the "make.pl" associated with that program.
We won't get into the debate of a company charging to access items in the public domain; they're a business after all.
I know this might be teaching your grandmother to such eggs to some of the more advanced users, but there may be other people on the verge of renaming all their files when switching to Strawberry Perl. Oh, I believe their program suite also include C, C++ and Fortran compilers (no, I've no idea either!). One downside: Due to all the extra program features they install, the directory is THREE TIMES LARGER than the "ActiveState" installation!
I'm pretty sure your problem with ActivePerl is that you're using an older version. I've just done:
C:\Users\myaccount\Documents>perl -MCPAN -e shell
It looks like you don't have a C compiler and make utility installed. Trying
to install dmake and the MinGW GCC compiler using the Perl Package Manager.
This may take a a few minutes...
Downloading ActiveState Package Repository dbimage...done
Downloading MinGW-4.6.3...done
Downloading dmake-4.11.20080107...done
Unpacking MinGW-4.6.3...done
Unpacking dmake-4.11.20080107...done
Generating HTML for MinGW-4.6.3...done
Generating HTML for dmake-4.11.20080107...done
Updating files in site area...done
2759 files installed
Please use the `dmake` program to run commands from a Makefile!
cpan shell -- CPAN exploration and modules installation (v2.05)
Enter 'h' for help.
cpan>
Using version:
This is perl 5, version 20, subversion 1 (v5.20.1) built for MSWin32-x86-multi-thread-64int
ActiveState has a policy of not keeping fully up to date on older versions, because of the support overhead. You can see - for example - their builds of dmake here:
https://code.activestate.com/ppm/dmake/
From their web page:
Looking for access to older versions of ActivePerl?
Community Edition offers access to the newest versions of ActivePerl.
Access to older versions (Perl 5.6, 5.8, 5.10, 5.12, 5.14, 5.16) is available in Business Edition and Enterprise Edition.
E.g. to use the version you're currently using (5.12), you'd need to buy support. But you could use 5.18 or 5.20 for free.
I would also note: Windows doesn't use shebang paths anyway; it uses file associations.
I've been playing around with Ruby for a while now and wanted to write my own gem. I wanted to write something simple but useful. My idea was to create a simple console gem that would alert a user when a new post was created in a certain subreddit. Right now it's hardcoded to one subreddit, and I'm using Mac's say command to notify me when there's a new post. My first question is, is this even gem-worthy? I could turn this into a simple Rails app, which might make things logistically easier. But I really wanna write up a gem.
If I do decide to carry on with the project as a gem, there are a few obstacles I have to get past. Right now I'm using whenever to run that runs my script every minute. To update your cron jobs, you have to run whenever --update-crontab in the directory of the project in order to set the cron job. This has become an issue for me, because I would like to be able to make the gem usable on installation without having a user do anything. So instead of having to run the command above, I'd like a user to just be able to download the gem and then, eventually, choose what subreddits and the frequency of the cron job (via a console menu).
Sorry for the length of the post, just looking for some input.
My first question is, is this even gem-worthy?
Yes.
I would like to be able to make the gem usable on installation without having a user do anything.
Use a ./bin directory that contains an executable script, that uses a sleep method.
My advice is don't alter the user's cron. Instead, include README help that explains how to cronify your bin executable.
Is it possible to install the entire database(postgresql8.2) via command prompt or batch file or registry file bypassing the trivial procedure for installation. But then to a question comes that, how can we supply default parameters such as name,password,language,default location of database? Currently I'm working on 'Windows XP' platform.
Thank you.
For 8.3 and lower the obvious answer is: http://pginstaller.projects.pgfoundry.org/ which supports or supported silent installations. For more recent versions, please read: http://forums.enterprisedb.com/posts/list/2135.page
Use of existing installers would simplify your life and be where I would start.
This being said there is no reason you can't generate a script to register dll's properly run initdb, etc. This will take some extra knowledge of both PostgreSQL and Windows, and will be mostly suitable for custom solutions (i.e. not cases where you merely are packaging software that runs with PostgreSQL). I don't think an complete answer can be given here because once you need such a solution you need to design your installation around if. Books could be written on that topic. The docs http://www.postgresql.org/docs/9.0/static/install-windows.html should get you started however since the only difference really between installing from source and installing from the precompiled source is just that you need to compile the source files first.
Failing that you could take a look at the binary zip packages. Typically these can be extracted and PostgreSQL can be run from inside them.