ruby / middleman noob, path issue when starting middleman on branch - ruby

I have a middleman server running fine on the trunk part of my repository.
when I try to start middleman on a branch, I get the following error:
Guard is now watching at '/Users/name.lastname/Foo/foo-html/branches/foo-html-1.2/src/main/resources/assets'
/Users/name.lastname/.rvm/gems/ruby-1.9.3-p327/gems/middleman-2.0.15.3/lib/middleman/core_extensions/features.rb:82:in `class_eval': cannot load such file -- helpers/application_helper (LoadError)
I use terminal to get to the relevant folder and use "bundle exec middleman". It looks like a path issue, something relative to the current directory when I run that command. What files should I look at to edit middleman's settings ?

that probably wont help anyone, but i had to comment out a few lines in config.rb, located in the root of the branch tree. like this :
# require 'helpers/application_helper'
# activate :application_helper

Related

Struggling to run my ruby cli app

I built a small Cli app in ruby (first ever ruby app), but I'm not able to actually run it.
I started the project off with bundle gem. I have been testing it inside my apps folder by running bundle exec bin/konstruct and everything works fine.
I want to install it locally and test it before I submit it, and so I ran bundle exec rake install after updating all of the info in my gemspec file. It gave successfull output:
konstruct 0.1.1 built to pkg/konstruct-0.1.1.gem.
konstruct (0.1.1) installed.
But when I run the app by entering $ konstruct it gives me an Could not locate Gemfile or .bundle/ directory error, unless I run it from within the root folder of the app.
I have tried to Google but I can't pin the results down to the same issue as I'm having. I've been having this problem even in development (How can I test my Ruby CLI app while still in development?)
I do have a Gemfile and it contains:
source 'https://rubygems.org'
# Specify your gem's dependencies in konstruct.gemspec
gemspec
I don't have a .bundle/ folder though. I'm not sure where/how that folder should be generated. I have run bundle and bundle install many times now.
I have a konstruct.gemspec file which contains: https://github.com/konstruct/konstruct.cli/blob/master/konstruct.gemspec
Most of that file is as it was generated. I just filled it in where I could.
I'm sorry if this is a stupid question, but I am super stuck.
You have the following line in your gemspec:
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
I believe that means if you move your executable file into an exe directory instead of a bin directory, it will work as you expect.
http://guides.rubygems.org/specification-reference/#executables
It turns out I am a first class idiot. Some time ago I added Konstruct in my .path file, which obviously was now overriding the proper konstruct command. Back then what I did din't work, so I just forgot about it.
So the answer to this question: It's not broken. OP is an idiot. :-/

Location of db/config.yml on a ruby app using standalone-migrations

I'm working on an command-line application that uses the standalone_migrations gem. I have the db/config.yml file and everything works fine when I run the app from the root dir, but when I run it from other dirs (e.g. directly running a script in the /bin directory), the gem cannot find the db/config.yml.
I looked at the gem's source, specifically in the lib/configurator.rb file, but couldn't find a way to set the correct .yml path.
Any help? Thanks.
StandaloneMigrations::Configurator uses relative paths, it loads configuration files on line #23.
This is a bug in the code. A workaround could be to change the working directory to the root before you execute the script. You didn't mention what kind of script you have under /bin, but for example if it is a Bash script, you can do something like:
cd /project/directory && rake db:migrate ...

Why am I getting this 'no such file to load' error with rake command?

I am working on lab 21 at this site. The directory path I have added the rakefile to is:
Now, it says I should be able to run the 'hello' program by invoking the 'rake' command from my console. However, when I enter the command I get the following back:
The line in question from the rakefile is as:
require './lib/hello'
I have followed this tutorial to the letter, so I don't believe it is a mistake with the filepath. But to be sure, I even reversed the directory names of hello and lib, like this, to be sure:
The tutorial is on git, not rakefiles, so it's not exactly a pressing issue, but it sure is annoying to not be able to figure it out.
Both images have conflicting directory structure, not sure which one's right. But, since your Rakefile and hello.rb are in the same directory, you need to change :
require ./lib/hello.rb
to
require ./hello.rb
It looks like you're already in the ./lib directory. Remove ./lib from the require:
require './hello'

Making rubygem - Error: uninitialized constant

I'm currently attempting to create a ruby gem out of a script and, while it works if I take the scripts and put them in the same directory, if I put them in the appropriate /bin and /lib directories after generating my gem structure, build the gem and then attempt to execute it I'm given the uninitialized constant error. Under /bin the relevant section in the file "cjp" is:
Cjb.new(crontabDir, logDir, allowedFrequency, printOnly, testRun).
find_violations autoFix
The class is defined in the file cjp.rb under /lib
class Cjb
def initialize(crontabDir, logDir, allowedFrequency, printOnly, testRun)
#crontabDir, #logDir, #allowedFrequency, #printOnly, #testRun =
crontabDir, logDir, allowedFrequency, printOnly, testRun
Despite this, the error I get is:
ERROR: uninitialized constant Cjb
I also noticed that if I attempt to manually execute the "cjp" script under /bin without the lib script being in the same directory that it also gives the same error. It appears that I'm missing something.
Any help on what I'm missing here to get this working would be appreciated.
bundle gem uses git to manage gem manifest.
If you do not see all your expected files when you run git ls-files in your gem project dir, then you need to add them.
To add individual files:
git add <filename>
To add everything (run from root of project):
git add .
This may have caught you out if you were not expecting to use git on your project. If you don't know git, and have time, it is really recommended to help you manage your project code. In fact so much so that bundle simply assumes that's what you want to do (although other code management tools are available)

Another place that project tool configuration files can be placed other than root?

When using multiple tools like Guard, Rake, and Bundler which store their configuration files in the projects root, the root folder starts to become cluttered with development debris like:
Guardfile
Rakefile
Gemfile
Gemfile.lock
And who knows what else if other tools are used...
Is there some where else that the configuration files for these tools can be stored that would still allow them to be invoked in the same manner?
Rake accepts --rakefile or -f [filename]
Bundler accepts --gemfile [filename]
You could therefore create a directory, e.g. 'toolfiles' and put Rakefile and Gemfile in there. You would be stuck, of course, with including the filename each time you used the tool.
I have no idea about Guardfile.

Resources