documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Capistrano in ruby script

Open ddarbyson opened this issue 12 years ago • 17 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 }

ddarbyson avatar Dec 03 '14 04:12 ddarbyson

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

Kriechi avatar Jan 15 '15 14:01 Kriechi

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.

ddarbyson avatar Jan 15 '15 16:01 ddarbyson

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?

Kriechi avatar Jan 15 '15 16:01 Kriechi

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

ddarbyson avatar Jan 15 '15 16:01 ddarbyson

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.

leehambley avatar Jan 18 '16 13:01 leehambley

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

will-in-wi avatar Jan 18 '16 14:01 will-in-wi

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!

leehambley avatar Jan 18 '16 14:01 leehambley

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

will-in-wi avatar Jan 18 '16 14:01 will-in-wi

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.

will-in-wi avatar Jan 18 '16 14:01 will-in-wi

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

leehambley avatar Jan 18 '16 14:01 leehambley

Actually, maybe it's just you're requireing the wrong thing? https://github.com/capistrano/capistrano/blob/45e851bdc5ed80970a7be90f080f030aa7386190/lib/capistrano/deploy.rb#L3

leehambley avatar Jan 18 '16 14:01 leehambley

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.

will-in-wi avatar Jan 18 '16 16:01 will-in-wi

Added a PR in case this is the way you want to go. https://github.com/capistrano/documentation/pull/155

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

will-in-wi avatar Jan 18 '16 16:01 will-in-wi

@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:

https://github.com/capistrano/capistrano/pull/1548

mattbrictson avatar Jan 18 '16 17:01 mattbrictson

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?

will-in-wi avatar Jan 18 '16 17:01 will-in-wi

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.

mattbrictson avatar Jan 18 '16 18:01 mattbrictson

This issue was moved to capistrano/capistrano#1764

leehambley avatar Aug 29 '16 08:08 leehambley