go get remote: The project you were looking for could not be found or you don't have permission to view it - go

I am using go 1.20.1 , Windows 10 x64, GoLand 2022.3.2 .
Go to ... , create file .netrc with content
machine gitlab.com login my_username password my_password
Set environment variable
then get dependency
go get gitlab.com/foo/bar/baa/fuu
Error
remote: The project you were looking for could not be found or you don't have permission to view it.
How to fix it?

First, make sure to use a PAT (Personal Access Token), not your actual GitLab account password, in %USERPROFILE%\_netrc.
Second use go get gitlab.com/foo/bar, not foo/bar/baa/fu.
As in go get gitlab.com/name_or_group/repo_name.

on Windows OS, it is not .netrc , it is _netrc (underscore character) , and not use password, use GitLab access token.

Related

How to update a GitHub access token via command line

I use the git integration with VSCode and got the notification today that I need to renew my access token. I did so and have my new token (which I obtained through the web interface). Now I need to set my local git configuration to use the new token instead of the old one which will expire in a few days.
The VSCode docs suggest the following:
To execute the 'GitHub: Set Personal Access Token' type Ctrl+Shift+p in VSCode to open the command palette and type 'GitHub: Set Personal Access Token'. You will then be prompted to enter the token generated from GitHub.
This option isn't available in my git integration in VS code (maybe I need an update?)
How can I do this from the command line?
If you want to update Github Personal Access Token in VSCode, you need to install Github Extension
You can also update Github Personal Access Token via command line
Open a command line and set the current directory to your project root
Run the command to set remote access via a token
git remote set-url origin https://username:token#github.com/username/repository.git
Example:
git remote set-url origin https://exampleuser:b8c28127***63gu56b2d#github.com/exampleuser/exampleproject.git
Not sure if you are running on windows, but modern git binaries are using windows credential manager to store the GitHub / Git authentication details. To modify them, go to the windows "credential manager". The procedure is detailed here: https://www.sqlservercentral.com/blogs/changing-git-credentials-in-windows

Use go get to require dependency from private github repo on WSL 2

I'm trying out WSL 2 on windows 10 and it's gone well so far, but I've been struggling for 2 weeks to make this work, because for some reason go get doesn't use or is not able to make the Git Credentials Manager to prompt for my credentials.
I followed this blog to set up WSL2 with GCM https://www.edwardthomson.com/blog/git_credential_manager_with_windows_subsystem_for_linux.html
And it works very good for most of the daily tasks like cloning, read and write. But when using go get I get this error.
go get <remote github repo>#<latest commit id>
go: <remote github repo> 681dceefc81203e094872401c184d038090d6049 => v0.0.17-0.20200501212733-681dceefc812
go get: <remote github repo>#v0.0.17-0.20200501212733-681dceefc812/go.mod: verifying module: <remote github repo>#v0.0.17-0.20200501212733-681dceefc812/go.mod: reading https://sum.golang.org/lookup/<remote github repo>#v0.0.17-0.20200501212733-681dceefc812: 410 Gone
server response:
not found: <remote github repo>#v0.0.17-0.20200501212733-681dceefc812: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/232ff028cb2fdebd254e30bfc612843483f0fe3fbeb18d5fc8fb4b20f21c9021: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Already tried ssh-keys and the solutions proposed here go get results in 'terminal prompts disabled' error for github private repo
But the error remains the same, when enabling env GIT_TERMINAL_PROMPT=1 nothing happens, I guess it's because WSL 2 doesn't have the permissions to do that. Anyway I also tried this tool https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux and by setting a variable for plain credentials store, it prompts in the terminal for credentials. But I'm using 2FA because it's required by the organization and the prompt only asks for username and password, so the authentication fails.
So I have to reach out to a mate who is using Mac. He is able to go get the dependency to affect go.mod, make a commit and push the change so I can pull it and continue from there. But of course this is not ideal, and he doesn't have any problem, he uses osxkeychain to manage his git credentials.
Anyone has faced this issue? or know how to solve it? Thank you so much in advance.
Go is not able to understand that certain modules are private and their checksum should not be validated against go's checksum library. The following error comes from that
verifying module: <remote github repo>#v0.0.17-0.20200501212733-681dceefc812/go.mod: reading https://sum.golang.org/lookup/<remote github repo>#v0.0.17-0.20200501212733-681dceefc812: 410 Gone
If possible use at least go 1.13 or, higher. Go had introduced an env variables by name GOPRIVATE, GONOPROXY and GONOSUMDB for managing private modules better. Simplest way to signal to Go that you are importing a private repo is to use GOPRIVATE. Set the pattern of private repos to GOPRIVATE env variable to suppress checksum validation and usage of GOPROXY. Example below avoids checksum for all repos in that hierarchy:
GOPRIVATE=github.com/<your org>/*
Check out answers here and here. You can also do go help module-private for help.

Heroku CLI authentication issue

After a fresh install of Heroku on Windows 7, I can't seem to authenticate from the command-line.
Running the command: heroku login prompts me to enter my credentials. After doing so, I received an error:
heroku: Enter your login credentials
Email: my_email
Password: ************
Error: ENOENT: no such file or directory, open 'z:/_netrc'
I am using PowerShell, and when I run the command cat z:/_netrc, I get this error:
cat : Cannot find drive. A drive with the name 'z' does not exist.
Z: is a network drive, and it is accessible from the file explorer.
I already have a .netrc file in my %HOME% path, but it does not contain the heroku login credentials.
Looking at the official documentation and CLI help, I couldn't find anything useful to fix this. How can I login to my heroku account?
> heroku version
heroku/7.16.6 win32-x64 node-v10.11.0
So, the issue is arising from not finding _netrc file on your local computer that is required to complete login with Heroku. I have decided to create the file into following location of my windows 10 computer:
cmd>set HomeDrive=C:/Users/your Windows username/AppData/Local/heroku
In my case,
cmd>set HomeDrive=C:/Users/CrazyMoby/AppData/Local/heroku
Finally I ran heroku login
The above step resolved heroku login issue in my case.
Use setx HOME <netrc_default_location>
where <netrc_default_location> can be:
<%NETRC%>\_netrc
<%HOME%>\_netrc
<%HOMEDRIVE%%HOMEPATH%>\_netrc
<%USERPROFILE%>\_netrc
Some clarification can be found here and here.
Probably it's your user <%USERPROFILE%>.
But if you don't need it, just remove _netrc file, reboot and log in again.
Run the following command in powershell and the problem should be solved.
$Env:HOMEDRIVE = "C:"
If you need more information, check out the docs on windows environment variables.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7
This way work for me. Write in PowerShell next code , where "paulob" need change to your user, because folser "_netrc" exist in:
$Env:HOMEDRIVE = "C:\Users\paulob\"
Try running it from GIT BASH cmd instead of PowerShell if you can, I had the same problem and it worked in my case.

Pycharm GitHub 'Push failed: fatal: Authentication failed'

Every time I try to push a repository in GitHub with Pycharm the it fails.
Push failed: fatal: Authentication failed for 'https://github.com/(my github repository)/'
In Settings->Version Control->GitHub, I filled the fields Host, Loging and Password (Auth Type: Password). Testing it: "Connection successful"
In Settings->Version Control->Git, Path to Git executable is seted with the full path, SSH executable: Buil-in
Pycharm version 3.1.1
Git version 1.8.4.msysgit.0
On Win 7.
I tried all but it worked me charm :
The problem I had : Every thing was working from terminal and from Github desktop as well.
But when I tried to PUSH/PULL from pycharm it wasn't working.
Reason : It happens because by-default pycharm save password locally in DB.
Work around: Go to File > Settings > Appearance & Behavior > System Settings> Passwords, clicked on 'Do not save..", restarted IntelliJ and VCS asked for password again.
It seems there is some issue (if using https) if username or password contains "some" special characters.
So, I've generated a secondary password ("personal access token") in GitHub's application settings page (using the "Create new token" button), I did copy this token. Then I've selected Auth Type: Token in Settings->Version Control->GitHub, and pasted the token.
Testing it: Connection successful for user . Now the git push works perfectly.
I struggled with this problem for half a day using Git in PyCharm.
Solution: Settings => Version Control => Git => ticked "Use credential helper" and then it worked perfect.
If your username or password has special characters, you can replace it with the Percent-encoding for theses characters.
for example, if your password is "test#2010", you will write it as "test%402010" and the config command will be like this
git config remote.origin.url https://{username}:test%402010#github.com/{repo_username}/{repo_name}.git
So I found the solution to my problem, and I hope this helps:
If you are using KDE, or Gnome, your "KDE Wallet", or "Gnome Keyring" manager will save your password when you push for the first time. However, if you enter the password wrong, these managers (ksshaskpass for KDE) will store the wrong password and will send the wrong password every time.
To fix this, open the appropriate manager and change the password. With KDE, it is in: Kick-off-menu > System Settings > Account Details > KDE Wallet, then click "Launch Wallet Manager", and find "ksshaskpass", expand it, and then expand "Passwords", then find your github registered email address there, click it, and on the right, click on "Show Contents". Now change that value (in case wrong password), then hit save. and you're done!
Now that means you don't have to type in your password each time for https push, and you don't have to use SSH keys either ;)
I came across this once. Turned out that the Web Credentials in the Credentials Manager stored an incorrect password for github.com and gitlab.com.
I removed that and it gave me the option to log in when I added a new repository.
Ok guys, I tried all suggested solutions and they did not worked for me.
I use git bash and bitbucket.
Finally I turned it upsidedown, and it worked - at least that way. I know this is difficult and foolish solution, but it worked.
So the steps:
you have your code on your local machine.
you have your repo /on bitbucket/
Delete your repo or make a new one with new name
Make a readme.md with the help of the /bitbucket's/ dashbord
clone the new repo
copy your files into this new folder which you want to push
do the git bash work (add,commit) and push it to the repo.
In PyCharm go to:
Settings > Version Control > Github > +
add credentials
AND:
Check your open browsers, when logging in from pycharm into GitHub a tab is opened to authorize Jetbrains the access to your Github account.
I am using High Sierra on an old iMac and originally tried to push a new local project to a new remote.
Unable to get authentication working on Terminal I then tried to use PyCharm as a vehicle to save the authentication token from Github.
In the past I was accustomed to the IDE prompting for the use of a token and even suggesting me to open Github.com to generate the appropriate one.
PyCharm was not able to push a new branch but it did not give any such hints for a solution in the error message
12:56 Push failed
git#github.com: Permission denied (publickey).
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Show details in console
My solution was to go into the settings and there I found the connection to Github unset - and I was able to link a token.
But I also had to set the remote with the HTTPS link. When I tried with the SSH URI it did not work.

Gitlab - Xcode Can't connect with remote repository

I am having troubles when I connect with my repository through Xcode.
I have a Gitlab version (full pre-)installed on TurnkeyLinux Virtual Appliance on a remote server.
In the Gitlab Web interface, I've created a new test user: "testuser" with a password "password" and a new project "testproject". This user was assigned to this project.
The git url project are:
HTTP: http://example.com/testuser/testproject.git
SSH: git#example.com:testuser/testproject.git
I can see the repositories folder rightly created with a "Terminal" through SSH connection.
Now, I want add this git repository to my Xcode repositories.
So, In
XCode > Preferences > Account
I'm trying add it, using both urls and my user credentials, but always receive the following message:
"Authentication failed because the name or password was incorrect."
Could anyone help me?
The user/password would only be needed for an http url, not an ssh one.
When using the http url to add a repo in your XCode Accounts, make sure there is no proxy which would prevent the resolution of the example.com server.
If it is still not working, then, as in "Authentification issue when pushing Xcode project to GitHub", try to use an url like:
https://testuser:password#example.com/testuser/testproject.git
Even if the problems seems solved I've found this question when I had the problem using XCode 10.
I tried logging in to GitHub and got the same error. The workaround described didn't fix my problem but I've found another solution on my own which I'd like to share – maybe it helps somebody ;)
My GitHub password included an 'ä' character (I'm German) and seems XCode and GitHub don't support the used encoding. After changing my password to something without an 'ä' it worked fine. Maybe it wasn't because of the 'ä' but it already helped to change the password - I don't know.
Thank you, but the reasons are Xcode seems a little crazy…
In
Xcode > Source Control > Test Project (master) > Configure Test Project…
I've just added my repository HTTP URL and credentials were not needed, and when I trying push/pull actions Xcode ask me for user/password.
Seems to be Repository in Preferences > Account doesn't work fine…
you'd better use the project configuration:
‘Source Control’ > ’(project name)-Master’ > ‘Configure (project name)’,
select ‘Remote’, choose ‘+’ > Add Remote
Name : origin
Address : git#gitlab.com:xxx/yyy.git
(Curiously it appears after this in the XCode prefs)
Don't forget: using SSH, the password is the one you used (keygen) when building the key !
I don't want to use HTTP! Key file under "git" user is very convenient and secure, I'm not going to type my password in a unencrypted URL entry in some plist file.
In my case, the problem was that Xcode was trying to use the wrong key file : .ssh/id_rsa instead of .ssh/id_dsa
Here using Xcode 7.3.1 and finally managed to push using ssh (and Gogs as github server) by doing so:
1) select the correct private key (there must also be the public key file present)
on Gogs side:
2) add that same key from the Gogs user Settings->SSH Keys
3) under admin panel: Dashboard: Operations: rewrite the authorised_keys file
Done

Resources