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: Support working directories containing whitespace #646

Merged
merged 6 commits into from
Oct 9, 2024

Conversation

osteensco
Copy link
Contributor

addresses #546 #472, probably more

I believe this solution is OS agnostic but happy to adjust if it doesn't work somewhere.

@osteensco osteensco changed the title encapsulate bin path with quotes to account for whitespace FIX: Support working directories containing whitespace Sep 21, 2024
@osteensco
Copy link
Contributor Author

osteensco commented Sep 23, 2024

sorry for the messy merges... I was having issues with some of the tests that seemed unrelated to my changes, and the build process on github kept failing so I tried to catchup since I saw there was a linter problem fixed.

I had the same issues with the tests trying to run them on the main branch of my fork as well, even when my fork was caught up.

I ended up just testing my PR manually on a local project and it works on my machine 🤷‍♂️ . Is there a known issue with some of the tests in their current state? I couldn't find any open issues about it.

@cosmtrek cosmtrek merged commit df13da5 into air-verse:master Oct 9, 2024
5 of 7 checks passed
@omarattia3143
Copy link

this is causing issue #659, I am not sure why does space in path an cause issues, test paths with spaces using windows 11 it works fine, so I am not sure how to test this but could you use something like this?
if strings.Contains(c.Build.Bin, " ") && !strings.HasPrefix(c.Build.Bin, "\"") && !strings.HasSuffix(c.Build.Bin, "\"") { c.Build.Bin = "\"" + c.Build.Bin + "\"" }

@cosmtrek
Copy link
Collaborator

@omarattia3143 Sorry for the bug, I don't have windows for testing, PR is welcome~

@omarattia3143
Copy link

@osteensco can you confirm that this PR still works with this code? I have only windows and I can not test your changes

this is causing issue #659, I am not sure why does space in path an cause issues, test paths with spaces using windows 11 it works fine, so I am not sure how to test this but could you use something like this? if strings.Contains(c.Build.Bin, " ") && !strings.HasPrefix(c.Build.Bin, "\"") && !strings.HasSuffix(c.Build.Bin, "\"") { c.Build.Bin = "\"" + c.Build.Bin + "\"" }

@@ -327,6 +329,9 @@ func (c *Config) preprocess() error {
// CMD will not recognize relative path like ./tmp/server
c.Build.Bin, err = filepath.Abs(c.Build.Bin)

// Account for spaces in filepath
c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin)

Choose a reason for hiding this comment

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

I think this is causing an error on Windows, the exe can't be found and the path includes escape characters like this:

'\"c:\\go\\hello\\tmp\\hello.exe\"' is not recognized as an internal or external command,
operable program or batch file.

When if it was actually missing the error would be: this when the exe is missing and I run it from a command prompt

'c:\go\hello\tmp\hello.exe' is not recognized as an internal or external command,
operable program or batch file.

@moboqe
Copy link

moboqe commented Oct 15, 2024

this is causing issue #659, I am not sure why does space in path an cause issues, test paths with spaces using windows 11 it works fine, so I am not sure how to test this but could you use something like this? if strings.Contains(c.Build.Bin, " ") && !strings.HasPrefix(c.Build.Bin, "\"") && !strings.HasSuffix(c.Build.Bin, "\"") { c.Build.Bin = "\"" + c.Build.Bin + "\"" }

This seems not working either

@omarattia3143
Copy link

@moboqe this is not merged, It works if you dont have space in your path, I made it so it can bypass the issue created by this PR.
I am not sure if this PR works for other platforms.
@cosmtrek I think the best is to revert this PR since the author is not responding and it is affecting all windows users

@moboqe
Copy link

moboqe commented Oct 15, 2024

@moboqe this is not merged, It works if you dont have space in your path, I made it so it can bypass the issue created by this PR. I am not sure if this PR works for other platforms. @cosmtrek I think the best is to revert this PR since the author is not responding and it is affecting all windows users

I mean this doesn't work for me related for this issue.
Yep, I also fixed those issue by adding check for space in path

@osteensco osteensco mentioned this pull request Oct 15, 2024
cosmtrek added a commit that referenced this pull request Oct 16, 2024
cosmtrek added a commit that referenced this pull request Oct 16, 2024
wafer-bw added a commit to searchspring/air that referenced this pull request Jan 31, 2025
* chore: bump go to 1.23 (air-verse#650)

* docs: update banner (air-verse#651)

* fix proxy retry loop (air-verse#635)

This addresses two bugs:
1) The loop could exit with an error condition present and fail to
   inform the user.
2) On Windows 11, syscall.ECONNREFUSED is not returned. Instead we
   receive net.OpError with a message similar to:

"unable to reach app: Get "http://localhost:7000/": dial tcp [::1]:7000: connectex: No connection could be made because the target machine actively refused it."

The Fix:
Since the retry loop is short; just 1 second maximum, we retry until no
error happens. If an error does occur, we inform the user.

* Use web page address when making request to reload proxy (air-verse#625)

* Use web page address when making request to reload proxy

Signed-off-by: Alexandra Fishova <yopoyka@yopoyka.com>

* Create event source with just a path because browser can handle address on its own.

Signed-off-by: Alexandra Fishova <yopoyka@yopoyka.com>

---------

Signed-off-by: Alexandra Fishova <yopoyka@yopoyka.com>

* fix the stop_on_error is false configuration does not work (air-verse#555)

* fix color output (air-verse#551)

* Set the Via header in proxy requests to origin and in client responses (air-verse#629)

* Set the Via header in proxy requests to origin and in client responses

* Remove pseudonym and use host only

* feat: Make include_file overrule include_ext, fixes: air-verse#350, base_on: air-verse#358 (air-verse#416)

* feat: Make include_file overrule include_ext

* feat: Make include_file overrule include_ext unittest

* fix: broken code (air-verse#652)

* feat: silent flag in .air.toml, suppressing all air prints (air-verse#641)

* feat: silent flag in .air.toml, suppressing all air prints

useful if the app being watched has structured outputs that are being
piped into subsequent program/s.

* update: add silent to air_example.toml

* FIX: Support working directories containing whitespace (air-verse#646)

* encapsulate paths with quotes to escape spaces

* encapsulate paths with quotes to escape spaces

* preprocess error in test

* Revert "FIX: Support working directories containing whitespace (air-verse#646)" (air-verse#665)

This reverts commit df13da5.

* refactor: remove unnecessary var copy in for (air-verse#682)

* docs: fix badge link in README-zh_cn.md (air-verse#681)

* refactor: simplify test asserts; enable testifylint (air-verse#680)

* Update unclear .profile changes in README.md (air-verse#684)

* Fix: typo in air_example.toml (air-verse#706)

* Implement kill delay on Windows (air-verse#552)

* fix color output

* Implement kill delay on Windows

* Revert the change on master

* Remove extra newline

* Handle absolute paths in config (air-verse#318)

* remove a data race by compiling the exclude regexes in the preprocess phase (air-verse#677)

the regex compilation was done lazily on first access but did not properly synchronize
for being accessed by multiple watcher goroutines

between the option of adding a mutex for something that (should) only ever happen
once and removing the potential for a race, this seems like the better choice

* catch and report start cmd failure rather than panicing (air-verse#676)

* do not report the process as running if it failed to start

* change the return values on error to match what the other platforms produce

* chore: fix test case TestRegexes

* air -h will be document of air

* Update README for air help command

* fix: default config override (air-verse#719)

* Avoid duplicating cors header. (air-verse#727)

* fix: typos (air-verse#728)

* wait for killfunc completion when shutting down current app (air-verse#670)

* wait for killfunc completion when shutting down current app

---------

Co-authored-by: jingdi.zhu <jingdi.zhu@bytedance.com>

* Feature: Show build errors when using proxy (air-verse#725)

* proxy: stream reload and error messages

* proxy: Console log on build failure

* proxy: show build errors in a modal

---------

Co-authored-by: xiantang <zhujingdi1998@gmail.com>

* Add exiter to test os.Exit case (air-verse#729)

authored-by: jingdi.zhu <jingdi.zhu@bytedance.com>

* Fix: using powershell instead of cmd /C (air-verse#708)

---------

Signed-off-by: Alexandra Fishova <yopoyka@yopoyka.com>
Co-authored-by: Rick Yu <m@c6k.app>
Co-authored-by: Greg Dietsche <greg@gregd.org>
Co-authored-by: Alexandra Fishova <yopoyka@yopoyka.com>
Co-authored-by: dengdajun <78243198+pyjcode@users.noreply.github.com>
Co-authored-by: 8LWXpg <105704427+8LWXpg@users.noreply.github.com>
Co-authored-by: dedalusj <dedalusj@gmail.com>
Co-authored-by: zhb127 <1224680008@qq.com>
Co-authored-by: ~ jesse ~ <113159758+jesses-code-adventures@users.noreply.github.com>
Co-authored-by: osteensco <86266589+osteensco@users.noreply.github.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Gourav Kolhatkar <gstar1525@gmail.com>
Co-authored-by: Olivia Bahr <ob.bahr@gmail.com>
Co-authored-by: ZipFile <lin.aaa.lin@gmail.com>
Co-authored-by: Isak Styf <isak@styfsoftware.se>
Co-authored-by: xiantang <zhujingdi1998@gmail.com>
Co-authored-by: Nemanja Milićević <the.nemanja.milicevic@gmail.com>
Co-authored-by: Brandon Bloom <brandon.d.bloom@gmail.com>
Co-authored-by: Nathan Baulch <nathan.baulch@gmail.com>
Co-authored-by: jingdi.zhu <jingdi.zhu@bytedance.com>
Co-authored-by: Polo123456789 <57022222+Polo123456789@users.noreply.github.com>
Co-authored-by: Po <73031052+n1vk@users.noreply.github.com>
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.

5 participants