You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to clone outside of GITHUB_WORKSPACE directory #197
Hi Guys. I have a directory where the source code is located. I'm trying to create an action to:
Pull the last code on that directory (example /home/my-code/src)
Run npm install on that directory
Run npm run build on that directory.
Anyway, I set the env var $GITHUB_WORKSPACE into my yml file, but it seems to be not respecting the directory where the code is cloned / pulled in.
My script:
name: Development Deploy
on:
push:
branches: [ develop ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [10.10.0]
steps:
- name: Updating base code from develop
uses: actions/checkout@v2
with:
ref: refs/heads/develop
GITHUB_WORKSPACE: /home/my-code/src
... Another steps here
The log says the following:
Added matchers: 'checkout-git'. Problem matchers scan action output for known warning or error strings and report these inline.
Syncing repository: repoowner/reponame
Working directory is '/etc/actions-runner/website/src/reponame'
Is there anyway I can use the existing directory to use the checkout action? I want this to be cloned on /home/my-code/src
Today the path input is the only way to change the directory where the code is cloned. Also there is a restriction that it must be under GITHUB_WORKSPACE. If you want to get around that limitation, you could add a run step to move or copy the folder - or soft/hard link too i guess but but might unexpected issues later 🤷♂
So we're running a self-hosted runner, so the runner is in /etc and we don't want our code to be on that location. @jsg2021
Thanks @ericsciple . The limitation with path parameter is as you said, it needs to be under GITHUB_WORKSPACE. Tried with absolute paths and ../../{blabla} but error hapenned.
Reacted by Aaron Bauman, AraHaan, John, Robert Craigie, mathildemerle, Sukka and DavidBojanicKitro
This is important functionality for our builds because we have long repository names. We're getting paths like: D:\a\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAA\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAAA\src\ALongProjectNameBBBBBBBBBBBBBBBB\ALongProjectNameBBBBBBBBBBBBBBBB.csproj
We're hitting MAX_PATH on Windows builds. We need to be able to checkout and build in a directory like: D:\a\s\src\ALongProjectName...
Reacted by Clare Macrae, Bill Henning, AraHaan, Antonio Miron, Brian Scholer, Anas Ghanem, Dhrumil Bhankhar, Jean-Paul Calderone, Miguel Ang RZ, Márton Szász and 19 more
I tried configuring self hosted runner as suggested by @pvanloo in above [comment] (#197 (comment)) and it worked for me.
If someone needs a specific workspace, I would suggest to give a try with self hosted runner and specify your workspace path in work folder configuration.
what is the workaround? fetch the branch as zip and extract into outside of workspace folder?
I put a workaround further up
One workaround might be to create a symbolic link
So under windows after the checkout for example
- name: Link working directory
run: New-Item -Path D:/rust -ItemType SymbolicLink -Value D:/a/rust-build/rust-build
That way a shorter path can be used.
Under Linux it'd be "ln -s" instead
That way you can for example extract things into D:/a/rust-build/rust-build, but then do any compiling via D:/rust as they both point to the same place
If you have a repository name that ends in a dot, you can't use the checkout action on a Windows runner, because the workspace directory is always the repository name, but Windows doesn't allow for directory names with a trailing dot...
See the issue we're in. I can't clone anywhere else other than the $GITHUB_WORKSPACE which is also the repo name (i.e. M.A.R.S.), which again can't be created on a Windows agent due to the trailing dot.
You may have missed the workaround in my comment further above:
I've worked around GITHUB_WORKSPACE by doing a manual git clone using commands since this action hardly saves any code anyway, which you can see in the link I posted above to my public GitHub Actions repository.
If you do a git clone in a shell run step you can put it anywhere you want and with any directory name you want as an extra arg to the git clone command.
Or is the problem you're having that the agent fails to spawn properly as it tries to pre-create the $GITHUB_WORKSPACE directory which fails even without using a checkout action?
I ran into issues using actions/checkout to clone a 2nd repository related to the .git subfolders conflicting, so I tried cloning into a directory in a tmp dir outside of GITHUB_WORKSPACE, which failed due to this issue. The git exit codes aren't really that informative of what is going on -- it would be nice if actions/checkout could give a better error message related to corner cases where it fails, such as cloning a git repository into a subfolder of another git repository (not talking about git submodules, just fetching another unrelated repository as a test for another piece of code).
Activity
jsg2021 commentedon Mar 25, 2020
I could be wrong, but I think that's a reserved variable that already has meaning in this system.
jsg2021 commentedon Mar 25, 2020
Why do you need to specify where the code is cloned? This action takes care of that for you.
ericsciple commentedon Mar 25, 2020
Today the
pathinput is the only way to change the directory where the code is cloned. Also there is a restriction that it must be under GITHUB_WORKSPACE. If you want to get around that limitation, you could add arunstep to move or copy the folder - or soft/hard link too i guess but but might unexpected issues later 🤷♂eabuslaiman30 commentedon Mar 25, 2020
So we're running a self-hosted runner, so the runner is in /etc and we don't want our code to be on that location. @jsg2021
Thanks @ericsciple . The limitation with path parameter is as you said, it needs to be under GITHUB_WORKSPACE. Tried with absolute paths and ../../{blabla} but error hapenned.
[-]Clone does not respect variable GITHUB_WORKSPACE[/-][+]Unable to clone outside of GITHUB_WORKSPACE directory[/+]ddrinka commentedon Sep 1, 2020
This is important functionality for our builds because we have long repository names. We're getting paths like:
D:\a\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAA\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAAA\src\ALongProjectNameBBBBBBBBBBBBBBBB\ALongProjectNameBBBBBBBBBBBBBBBB.csprojWe're hitting MAX_PATH on Windows builds. We need to be able to checkout and build in a directory like:
D:\a\s\src\ALongProjectName...dukeofphilberg commentedon Sep 23, 2020
Perhaps you could create a symlink from the github workspace folder (_work by default) to another location.
This won't help long repository names though..
AzfaarQureshi commentedon Oct 5, 2020
I was running into the same issue, @ericsciple thanks for the workaround suggestion! :)
do you know if the
$GITHUB_WORKSPACEvariable can be changed elsewhere?gengjiawen commentedon Oct 19, 2020
On windows, too
Don't enforce that checkout path must be inside of Github Workspace
Don't enforce that checkout path must be inside of Github Workspace
Don't enforce that checkout path must be inside of Github Workspace
moelleru commentedon Dec 10, 2020
Hi, running into the same issue. Thanks to @LebedevRI for the fix. But any idea when this fix will be available?
nitin-jci commentedon Dec 22, 2020
I tried configuring self hosted runner as suggested by @pvanloo in above [comment] (#197 (comment)) and it worked for me.
If someone needs a specific workspace, I would suggest to give a try with self hosted runner and specify your workspace path in work folder configuration.
32 remaining items
jakoch commentedon Sep 19, 2023
what is the workaround? fetch the branch as zip and extract into outside of workspace folder?
seems
mv folder ..Hecatron commentedon Sep 19, 2023
I put a workaround further up
That way you can for example extract things into D:/a/rust-build/rust-build, but then do any compiling via D:/rust as they both point to the same place
ManikantaVenkateshappa commentedon Sep 19, 2023
Please check if this helps: #197 (comment)
accodev commentedon Nov 24, 2023
I have made this PR #1493 exactly for this issue.
WiehanVanNiekerk commentedon Feb 23, 2024
I'm doing another follow-up on this request regarding PR #1493
WiehanVanNiekerk commentedon Feb 23, 2024
@cory-miller, @takost , @luketomlinson
eXpl0it3r commentedon Apr 11, 2024
If you have a repository name that ends in a dot, you can't use the checkout action on a Windows runner, because the workspace directory is always the repository name, but Windows doesn't allow for directory names with a trailing dot...
For example: M.A.R.S.
HariSekhon commentedon Apr 11, 2024
@eXpl0it3r why don't you just check out to an explicitly specified directory name like
mars?eXpl0it3r commentedon Apr 11, 2024
See the issue we're in. I can't clone anywhere else other than the
$GITHUB_WORKSPACEwhich is also the repo name (i.e. M.A.R.S.), which again can't be created on a Windows agent due to the trailing dot.HariSekhon commentedon Apr 11, 2024
You may have missed the workaround in my comment further above:
If you do a
git clonein a shell run step you can put it anywhere you want and with any directory name you want as an extra arg to thegit clonecommand.Or is the problem you're having that the agent fails to spawn properly as it tries to pre-create the
$GITHUB_WORKSPACEdirectory which fails even without using acheckoutaction?eXpl0it3r commentedon Apr 11, 2024
That's possible indeed, I mostly wanted to report this additional limitation/issue with the Action as is
revert to cloning defang and samples into cwd
revert to cloning defang and samples into cwd
nightlark commentedon Nov 19, 2024
I ran into issues using
actions/checkoutto clone a 2nd repository related to the .git subfolders conflicting, so I tried cloning into a directory in a tmp dir outside of GITHUB_WORKSPACE, which failed due to this issue. The git exit codes aren't really that informative of what is going on -- it would be nice if actions/checkout could give a better error message related to corner cases where it fails, such as cloning a git repository into a subfolder of another git repository (not talking about git submodules, just fetching another unrelated repository as a test for another piece of code).Work around actions/checkout#197