capistrano / documentation

Home Page:https://github.com/capistrano/capistrano/tree/master/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Capistrano in ruby script

ddarbyson opened this issue · comments

I could not get this to work with the following line found at http://capistranorb.com/documentation/advanced-features/capistrano-pure-ruby/

Dir.glob('capistrano/tasks/*.rake').each { |r| import r }

However, using load seems to work just fine

Dir.glob('capistrano/tasks/*.rake').each { |r| load r }

Did you get any specific error message?
I just tried it in a blank irb context without getting any errors...

It's been a while so I don't quite remember. Since this post, I haven't change from load r so I'm assuming the issue is still there.

If you could supply more context would be great.
Otherwise this might be pretty hard to track down...

Did you get an error?
Did the .rake load - or not?
Did you have any .rake files - or was the directory-tree missing?
Capistrano version?

No problem. I'm actually am kicking up some development in a couple weeks. I'll keep this flagged and report back my findings.

Actually we kinda have this https://vimeo.com/133892224 - might serve as a reference. For a complete picture, I used to maintain a "Capistrano Handbook", which I was in talks to make into a real book - but another book which I can't seem to find now was published in the meantime, so we elected not to do it.

I'm confused. I don't see any reference to single ruby file Capistrano deployment in the video.

yep, useless link, my bad - I thought this was the "document an end to end setup of Cap" ticket for which I wanted to make a text version of the video. Sorry for wasting 10 mins of your life!

Heh, no waste, I now know about Harrow and the SSHKIT_COLOR param, both of which were new to me.

I'm trying to set up an example single script deployment. It looks like the require structure has changed since the docs were written, for example, Capistrano::Application.invoke('production') doesn't work, and I'm getting errors such as Don't know how to build task ':check'. I'll see if I can figure out why deploy.rake isn't getting pulled in.

Thanks @will-in-wi it's been a long time since it worked as documented, entierly possible that a world of things has changed. Interesting is that "deploy.rake-missing" hints might be found in the tail end of @mattbrictson 's "how to load a rakefile" stuff in his new Cap plugin branch... lemme see if I can find a reference

I'm not sure the code as written in the docs has ever worked. I pointed it at a local copy of Capistrano and started bisecting. The commit which created capistrano/all still has the Don't know how to build task 'production' error. The same errors that exist today existed as of 3.0.0.

I'm not having any success in writing a new single file example.

I'm inclined to say that this doc page should be entirely removed to avoid misleading people. I'm happy to make a PR to that effect. If this is useful, then perhaps a new ticket for the maintainers of Capistrano to figure this out would be in order.

Added a PR in case this is the way you want to go. #155

At a bare minimum, it might make sense to remove it pending writing a new one.

@will-in-wi @leehambley I have a open PR to reinstate the Capistrano-in-a-script behavior. It still needs tests and a CHANGELOG, but it is ready for feedback:

capistrano/capistrano#1548

It looks like we could put back the docs using the contents of capistrano/inline as part of the script. Once capistrano/inline becomes part of Capistrano, the docs could be simplified.

Does this sound like a reasonable solution?

Unfortunately the capistrano/inline script only works if certain changes are made to Capistrano's setup.rb.

-    load deploy_config_path
-    load stage_config_path.join("#{stage}.rb")
+    load deploy_config_path unless deploy_config_path.nil?
+    load stage_config_path.join("#{stage}.rb") unless stage_config_path.nil?

So I don't think we can offer it as a solution in the docs until part or all of that PR is merged.

This issue was moved to capistrano/capistrano#1764