Skip to content

fixed #252 #253

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

Merged
merged 4 commits into from
Oct 11, 2018
Merged

fixed #252 #253

merged 4 commits into from
Oct 11, 2018

Conversation

PatrickBuTaxdoo
Copy link
Contributor

See #252

Fixed a bug when loading requirements.txt on windows machines with dockerizePip set to false

@dschep
Copy link
Contributor

dschep commented Sep 20, 2018

@heri16 @kichik, you're kinda my resident Windows experts. Does this change make sense to you?

@dschep dschep mentioned this pull request Sep 20, 2018
@AndrewFarley
Copy link
Contributor

AndrewFarley commented Sep 20, 2018

Not an expert on Windows, but I'd say this looks good, it should always need to be escaped I believe. In similar news @dschep any ideas on bootstrapping a CI script / env on Windows? I did manage to setup a docker toolbox on my windows box here, so I can do tests before releases, we just need to script the existing tests in a windows-friendly way. I can't seem to find a web based CI or cloud provider that has windows with docker, maybe there is one though. Seems like a gap in the CI market, but I'd like to make our Windows guys stop feeling abused from breaking builds. :P

@dschep
Copy link
Contributor

dschep commented Sep 20, 2018

re CI - yes. I have a WIP of porting the tests from bats to tape which should make the tests runnable on windows. Docker support will be trickier, but even just non-docker tests will be WAAYYY more covg than we have now 😄

@kichik
Copy link
Contributor

kichik commented Sep 20, 2018

I think this would hide the actual error. Instead of \\, we would have // which Windows seems to handle better in this case. But if the path to convert would be a network path (starting with double back slashes - \\) this code might change the meaning of the path.

@PatrickBuTaxdoo do you know why the path ends up with double slashes in the first place? Is the single_quote() function messing it up or was it like that before?

On a separate note, dockerPathForWin() might need a new name if it's used for both Docker and non-Docker paths.

@dschep dschep added the Windows label Sep 20, 2018
@PatrickBuTaxdoo
Copy link
Contributor Author

@kichik I think the single_quote function is messing up.

I modified the function like this:

function dockerPathForWin(options, path) {
  console.log(path);
  console.log(quote_single(path));
  console.log(path.replace(/\\/g, '/'));
  if (process.platform === 'win32') {
    return path.replace(/\\/g, '/');
  }
  return quote_single(path);
}

And got this additional output:

C:\Users\[...]\.serverless\requirements
C\:\\Users\\[...]\\.serverless\\requirements
C:/Users/[...]/.serverless/requirements
C:\Users\[...]\.serverless\requirements\requirements.txt
C\:\\Users\\[...]\\.serverless\\requirements\\requirements.txt
C:/Users/[...]/.serverless/requirements/requirements.txt

So the path before passing it to single_quote was just fine.

But if figured that it works without modifying the path for my configuration, so this fix should be more appropriate as it is less likely to break compatibility with docker builds:

function dockerPathForWin(options, path) {
  if (process.platform === 'win32' && options.dockerizePip) {
    return path.replace(/\\/g, '/');
  } else if (process.platform === 'win32' && !options.dockerizePip) {
    return path
  }
  return quote_single(path);
}

I added a commit to this PR.

@kichik
Copy link
Contributor

kichik commented Sep 21, 2018

So the other thing quote_single() should be doing is quoting paths with spaces. I think it might be better to find a library that handles this quoting properly on both Windows and Linux. Otherwise we'd have to handle escaping unique characters and spaces ourselves.

@dschep
Copy link
Contributor

dschep commented Sep 21, 2018

So, my initial searching doesn't seem to indicate thare are any shell escape libraries for windows, @kichik. 😦

@dschep dschep merged commit a42eee3 into serverless:master Oct 11, 2018
@dschep
Copy link
Contributor

dschep commented Oct 11, 2018

So, I'm gonna merge this for the time being. Better than nothing.

@PatrickBuTaxdoo PatrickBuTaxdoo deleted the fix-252 branch October 12, 2018 07:56
bweigel pushed a commit to bweigel/serverless-python-requirements that referenced this pull request Nov 17, 2018
- this was probably missed during merge of serverless#253
bweigel pushed a commit to bweigel/serverless-python-requirements that referenced this pull request Nov 18, 2018
- this was probably missed during merge of serverless#253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants