Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for parsing ls output in detect_manifest_path #133

Merged
merged 1 commit into from
Jan 19, 2016

Conversation

januszm
Copy link
Contributor

@januszm januszm commented Aug 17, 2015

NOTICE: we probably should use a different approach than parsing ls results

NOTICE: we probably should use a different approach than parsing ls results
@januszm
Copy link
Contributor Author

januszm commented Aug 18, 2015

O wow, there are several forks that include almost similar fix. Why the fix is not yet merged?

@januszm
Copy link
Contributor Author

januszm commented Sep 14, 2015

bump, I've seen some new commits that were merged to master in the past few days. Could you guys also take a look at this PR ?

@maartenvanvliet
Copy link

👍

@mcfiredrill
Copy link

Having the same issue.

@januszm
Copy link
Contributor Author

januszm commented Oct 30, 2015

@kirs what do you think?

@carld
Copy link

carld commented Nov 2, 2015

Same here

diff --git a/lib/capistrano/tasks/assets.rake b/lib/capistrano/tasks/assets.rake
index 803cefa..465c5cc 100644
--- a/lib/capistrano/tasks/assets.rake
+++ b/lib/capistrano/tasks/assets.rake
@@ -66,9 +66,11 @@ namespace :deploy do
         within release_path do
           backup_path = release_path.join('assets_manifest_backup')

+          manifest_path = detect_manifest_path.gsub(/\n/, ' ')
+
           execute :mkdir, '-p', backup_path
           execute :cp,
-            detect_manifest_path,
+            manifest_path,
             backup_path
         end
       end
--

@hishammalik
Copy link

+1 for the fix

@aligo
Copy link

aligo commented Nov 14, 2015

+1 for this

@czimmerman
Copy link

Any reason this hasn't been merged yet? Thank you for this.

@joren
Copy link

joren commented Dec 1, 2015

👍 fixed it for me as well.

@jemiam
Copy link

jemiam commented Dec 22, 2015

👍

@LuanJames
Copy link

+1

@mcfiredrill
Copy link

Have the maintainers seen this PR? Is this a good fix? Any feedback?
This is not an issue if you only have one manifest file.
I suspect there might be an underlying issue, or is there a good use case for having more than one manifest file?

@mattbrictson
Copy link
Member

I don't have a test case to prove it, but I think this approach will fail during restore_manifest. I think a more robust solution is needed that loops over each manifest file rather than concatenating multiple paths with spaces, which is prone to error when you pass that string around to different shell commands.

TBH, the lack of unit tests (or any kind of tests whatsoever) in this project makes me hesitant to add code to fix an edge case like this. I'd worry about inadvertently breaking something.

However, in place of tests, if you can post Capistrano logs that show a PR successfully doing both a backup and a restore with multiple manifests, I'll consider merging it.

Sorry for being a downer, I know this is a big sore spot for those running into the multiple manifests problem. I just want to make sure we do this right.

Also, does anyone have a theory for how multiple manifests come to exist in the same assets directory in the first place?

@mcfiredrill
Copy link

@mattbrictson Thanks alot for taking the time to respond.

I had a feeling there was a more robust solution...

Maybe its worth getting this merged to help in the short term though.
When does restore_manifest happen exactly? I could try to test it.

@mattbrictson
Copy link
Member

When does restore_manifest happen exactly?

During cap deploy:rollback (see rollback docs).

I could try to test it.

That would awesome!

@januszm
Copy link
Contributor Author

januszm commented Jan 19, 2016

Guys, a fix that works, even if as simple as mine, is better than no fix.

I see two main issues here:

  1. For some reason sometimes multiple manifest files appear. This is a different story, an issue that probably should be addressed somewhere else and deserves its own pull request.
  2. A code that relies on parsing output from LS command was added, whoah! long time ago. This was not the best solution for the problem the original developer tried to solve. Parsing output from ls is unsafe. If there's more than one result from ls, most probably the output string will contain the newline characters.

In my humble opinion you should merge this fix and work on resolving the issue with multiple manifest files in a separate thread. I've been using this fix for months already, I've made dozens of deploys, even one rollback, and never had issues with it.

kirs added a commit that referenced this pull request Jan 19, 2016
Fix for parsing ls output in detect_manifest_path
@kirs kirs merged commit c0be43d into capistrano:master Jan 19, 2016
@kirs
Copy link
Member

kirs commented Jan 19, 2016

Thank you all for the discussion and sorry for the late reaction.

@kirs
Copy link
Member

kirs commented Jan 19, 2016

I agree that there should be a better way than parsing ls output, but so far it's the only approach that we use in Capistrano (https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/deploy.rake#L193) - but we're open so suggestions!

kirs added a commit that referenced this pull request Jan 19, 2016
@kirs
Copy link
Member

kirs commented Jan 19, 2016

v1.1.6 released 🚀

@mcfiredrill
Copy link

Great, I can at least stop using a fork for now.
If there's an issue with rollbacks I imagine we'll hear about it soon... 💦

sbonami added a commit to sb-archive/capistrano-rails that referenced this pull request Sep 13, 2016
…ride-setting

* upstream/master: (24 commits)
  Preparing v1.1.8
  Bring README up to date
  Handle arrays in normalize_asset_timestamps (capistrano#185)
  Updated configuration to avoid setting migration servers and improved recommendation
  Added recommendations section
  Remove duplicate explanations of :migration_role in README.md
  Your contribution goes here
  Add 1.1.7 release notes
  Prepare for 1.1.7
  Fix code on README
  Allow overriding migration servers
  call Array#uniq to remove duplicated :linked_dirs
  Complete installation instructions
  Prepare for 1.1.6
  Changelog for capistrano#133 /cc @januszm
  Moving capistrano related gems under the dev group
  Update changelog
  Update changelog
  Escape [ and ] when calling assets:clean rake task
  add clobber assets
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.