Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I place custom executables in a Rails project

I have been using bin/ to place my various bash scripts. I remember reading that this is incorrect because of bundle install --binstubs, which would be confusing to be mixed with our own bash scripts (or might even overwrite, causing a conflict).

I vaguely think that the correct answer is script/, but I think that may also not be right.

Obviously the "answer" doesn't matter much, but if there is a standard location, I think it would make sense to use it.

like image 563
Joel McCracken Avatar asked Oct 22 '22 17:10

Joel McCracken


2 Answers

There doesn't seem to be a "correct" answer for this. It's something I've looked for several times in the past, but I have never been satisfied enough to think of something as an agreed-on standard.

In practice, I've seen binaries placed in script/ (do you really think that whole directory should have only one file?), lib/script (I can see the logic behind this, fitting with other "lib"-like things), lib/<various subdirectories> (for more-organised use of lib/) or rewritten to be rake tasks (lib/tasks)

like image 148
Will Palmer Avatar answered Nov 15 '22 05:11

Will Palmer


I looked for it in bundler and I found out this issue: https://github.com/carlhuda/bundler/issues/1250

They sad that binstubs can take values, so you can point the binstubs somewhere else. So the solution is the opposite of what you thought, you will point the binstubs to another path and keep your scripts in /bin.

 bundle install --binstubs some_value
like image 38
Bengineer Avatar answered Nov 15 '22 05:11

Bengineer