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

(maint) Module install - ensure paths use / #171

Merged
merged 2 commits into from
Jan 3, 2017

Conversation

ferventcoder
Copy link
Contributor

Due to https://tickets.puppetlabs.com/browse/PUP-4884, modules
may fail to install on Windows. It's also somewhat hard to detect
this is occurring. Grab the full path every time for install and
ensure that the paths use forward slashes only.

cc @puppetlabs/modules

Due to https://tickets.puppetlabs.com/browse/PUP-4884, modules
may fail to install on Windows. It's also somewhat hard to detect
this is occurring. Grab the full path every time for install and
ensure that the paths use forward slashes only.
@puppetcla
Copy link

CLA signed by all contributors.

working_dir = File.expand_path('spec/fixtures/work-dir')
working_dir = working_dir.gsub(/\\/, '/')
target_dir = File.expand_path('spec/fixtures/modules')
target_dir = target_dir.gsub(/\\/, '/')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit of overkill. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidS let's chat here. I mentioned that the gsub bits are maybe a bit of overkill and probably unnecessary. This is fixing the issue with PUP-4884 in that it doesn't switch the paths to forward slashes by switching the paths to forward slashes here. I don't have a mistrust for File.expand_path, but maybe you didn't quite catch my humor here.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't make the connection between PUP-4884, where a path with backslashes is specified as an argument, and this piece of code, which used hard-coded values with slashes before. Given your mistrust against File.expand_path, the updated version seems even worse than before.

Do you have a failing test log somewhere, or is this purely pro-active defensiveness?

@ferventcoder
Copy link
Contributor Author

Do you have a failing test log somewhere, or is this purely pro-active defensiveness?

I don't usually provide PRs for things that are just being proactive. Yes this fixes the issue. And like I said, it's maybe a bit of overkill because the gsubs probably are not required when we use expand_path.

@ferventcoder
Copy link
Contributor Author

This issue is why windows modules can't modulesync up to the latest puppetlabs_spec_helper and are pinned to a particular version. It may not be the only issue, but this is a start down the correct path.

@ferventcoder
Copy link
Contributor Author

ferventcoder commented Dec 29, 2016

Or put another way, without this change, PSH fails on Windows nearly every time.

" --module_working_dir spec/fixtures/module-working-dir" \
" --target-dir spec/fixtures/modules #{remote}"
" --module_working_dir #{working_dir}" \
" --target-dir #{target_dir} #{remote}"
Copy link
Contributor Author

@ferventcoder ferventcoder Dec 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have mentioned it is not super easy to see what is going on, that is why this took longer to find. This change is going from specifying a relative path to specifying a full path (using File.expand_path). The problem with the relative path is that PMT doesn't expand the path properly and so it becomes something like C:\somewhere\backslashes/spec/fixtures/work-dir on Windows, and then it fails (which is noted in PUP-4884).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! this was the piece I missed. Apologies! 🤦‍♂️

If you could put the "The problem with the relative path..." sentence into a comment in the code, that would go a long way towards making it clear for future-us to understand what's going on here.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I finally understood what's going on, I'm fine with this going in.

This wraps up the conversation from the original PR and will hopefully help us in a year when we want to remove that again.
@tphoney tphoney merged commit 2f22889 into puppetlabs:master Jan 3, 2017
@ferventcoder
Copy link
Contributor Author

\o/

@@ -292,11 +292,17 @@ def max_thread_limit
end
next if File::exists?(target)

# The problem with the relative path is that PMT doesn't expand the path properly and so passing in a relative path here
# becomes something like C:\somewhere\backslashes/spec/fixtures/work-dir on Windows, and then PMT barfs itself.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ferventcoder ferventcoder deleted the ticket/maint/expand_path branch January 3, 2017 17:26
@ferventcoder
Copy link
Contributor Author

Thanks for following that up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants