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

Allow users to opt-out of apt repository install #22145

Open
jandsu opened this issue Mar 7, 2017 · 13 comments · May be fixed by #227837
Open

Allow users to opt-out of apt repository install #22145

jandsu opened this issue Mar 7, 2017 · 13 comments · May be fixed by #227837
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities install-update VS Code installation and upgrade system issues linux Issues with VS Code on Linux on-release-notes Issue/pull request mentioned in release notes on-testplan
Milestone

Comments

@jandsu
Copy link

jandsu commented Mar 7, 2017

  • VSCode Version: Code 1.10.1 (653f873, 2017-03-02T00:47:58.633Z)
  • OS Version: Linux x64 4.4.0-64-generic
  • Extensions: not relevant

My team and I use Artifactory to cache locally the .deb files rather than downloading from the Internet over and over again.

The consequence is that a dev's box has a single sources.list file holding all the entries reading from the site-local cache rather than from the Internet.

This eventually leads to following error when installing VS Code:

$ sudo apt-get install code
...
/var/lib/dpkg/info/code.postinst: line 66: /etc/apt//sources.list.d/vscode.list: No such file or directory
dpkg: error processing package code (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 code
E: Sub-process /usr/bin/dpkg returned an error code (1)

Steps to Reproduce:

  1. Configure the GPG key and APT repository manually (inspired by https://code.visualstudio.com/docs/setup/linux#_installation but using other files / folders to suite needs of site-local cache)
  2. run sudo apt-get install code
  3. the script /var/lib/dpkg/info/code.postinst fails as shown above

==> this script seems to silently try to add the repo to the sources list of the user.

This is not the Ubuntu / Debian usual way

This may be a good idea for the .deb downloaded from the web site directly, but it should not be run when the user has already configured his system to grab VS Code from a repo (Microsoft's or another) somewhere.

How can you know if the repo is already configured?
You may run apt-cache madison code to check if VS Code can be found and where.

The key is that the user should not be forced to have the GPG key and the apt source configured as you expect, because some of them will simply have different requirements.

Thanks

@jandsu
Copy link
Author

jandsu commented Mar 7, 2017

Actually; I just realized that the reason of the failure is because I simply removed the folder /etc/apt/sources.list.d and all my sources are in a single file, which I get easily on all developer's boxes using a simple curl command.

If the folder still, exists there is no failure, however, vscode still has added its own repo... which I want to avoid to use our local cache.

@ramya-rao-a ramya-rao-a added the linux Issues with VS Code on Linux label Mar 7, 2017
@Tyriar
Copy link
Member

Tyriar commented Mar 9, 2017

It would be good to have some check(s) to see if we should not set up the folder, such as checking if vscode.list exists, checking an environment variable etc.

@Tyriar Tyriar added debt Code quality issues install-update VS Code installation and upgrade system issues labels Mar 9, 2017
@Tyriar Tyriar added this to the Backlog milestone Mar 9, 2017
@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Mar 9, 2017
@jandsu
Copy link
Author

jandsu commented Mar 9, 2017

Hello @Tyriar,

As explained earlier in this report, the vscode.list does not necessarily exist, so checking this is not reliable. What you want to know is if the code package is to be found somewhere using the current configuration.

This can be done easily by checking the return code of dpkg -l code.

Check for instance the following command on a system with the vscode repo setup and on another with the vscode repo not setup and see the difference for yourself.

apt-cache show code &> /dev/null && echo found || echo not found

Nevertheless, be warned, adding a new repo source on a system is not very common and may upset some users, in particular advanced users (who are the target audience of vscode).

On my box for instance, unless I edit the offending script to insert an exit 0, I can no longer run system updates w/o an error.

Edition: fixed the command to use a functional one

@Tyriar
Copy link
Member

Tyriar commented Mar 10, 2017

@jandsu your examples aren't really what we want though. We want to make it as streamlined/easy as possible to get automatic updates working for users. Just checking for the presence of the code package would not install the repo when upgrading from older versions to newer versions for example. The way Chrome does it which is probably what we will want to do is check vscode.list and update it only if it does not exist or has been disabled after upgrading the OS (ie. don't touch if it's been commented out manually),

It will annoy some users but there would be ways to disable it (eg. env var or modified vscode.list), the benefits of enhanced security, staying up to date and not annoying the user with the download now popup far outweigh a little annoyance to powerusers that has workarounds. An apt developer actually recommended Chrome's approach in #2973 (comment)

@jandsu
Copy link
Author

jandsu commented Mar 13, 2017

@Tyriar, you are right: in my attempt to be able to check the status code of the command (and be able to reliably call it from a script), I overlooked the fact that those commands would issue "found" when the package is only installed manually as former vscode versions. Sorry about that.

So please disregard these examples... my original issue description was referencing apt-cache madison and this one works well to check whether the package is grabbed from a repo or not.

Unfortunately it has no status code returned and you'd have to parse the output... not very satisfying...

Anyway, I clearly understand the goal which is very nice! And thanks for the link... BTW, you will notice that two comments below (in #2973 (comment)) the recommended way is to have 2 separated packages:

  • one for configuration
  • one for the actual program

In that case, the user is free to install one or the other... This is obviously a bit less convenient for non-power users...

I don't want to seem to push hard in one or the other direction: I will not pretend that I am a specialist in .deb repos, it is just that vscode is the single package that breaks our local cache configuration right now... whatever way you pick up to circumvent the issue will be fine by me :)

@Tyriar
Copy link
Member

Tyriar commented Mar 13, 2017

@jandsu thanks for your understanding, I think doing both checks before writing the vscode.list will be best:

  1. If a $VSCODE_SKIP_REPO (or similar) is set, skip the repo/key install
  2. If vscode.list has been modified and its contents is not recognizable (eg. it's commented out), skip the repo/key install

Not sure I'll be able to get to this in March but open to PRs in the meantime.

@Tyriar Tyriar changed the title Repository install does not fit standard Debian/Ubuntu practice Allow users to opt-out of apt repository install Apr 21, 2017
@Tyriar Tyriar added feature-request Request for new features or functionality and removed debt Code quality issues labels Sep 12, 2018
@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2019

Closing for housekeeping purposes the lack of interest. Still open to PRs if you care though.

@Tyriar Tyriar added the *out-of-scope Posted issue is not in scope of VS Code label Oct 9, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 9, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@DimanNe
Copy link

DimanNe commented Jul 31, 2023

@Tyriar Thank you for pointing out that my issue was a duplicate of this.

Just to double-check, am I right that you are not opposed to these:

  • If a $VSCODE_SKIP_REPO (or similar) is set, skip the repo/key install
  • If vscode.list has been modified and its contents is not recognizable (eg. it's commented out), skip the repo/key install

Regarding the environment-variable approach: this variable should be set in the apt (or root) user, right?

Would you consider other approaches, such as:

  • if there is vscode.sources (or any .sources file with predefined name) do not install vscode.list
  • if there is I-will-be-maintaining-my-own-vscode-file-do-not-add-your-own.list (or any other .list file with predefined name) do not install vscode.list

^^^^ what I am trying to say is that there might be a mechanism that signals vscode that user has custom *.sources / *.list and that vscode should not try installing its own.

@Tyriar
Copy link
Member

Tyriar commented Jul 31, 2023

@DimanNe yes those 2 would be good if they were contributed, another approach is to have a hard coded string like # vscode-skip-repo in the .list. Whatever happens we could document it at https://code.visualstudio.com/docs/setup/linux.

Yes, the environment variable would need to be set for whatever user runs apt.

m-byte added a commit to VOGL-electronic/vscode that referenced this issue Jul 9, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Jul 9, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Jul 9, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
@m-byte
Copy link
Contributor

m-byte commented Jul 9, 2024

@Tyriar I just opened a PR for this (#221285). I felt like the most Debian way of approaching this would be using debconf, not environment variables.

For automatic installations, users can use debconf-set-selections to set code/add-microsoft-repo to either true or false before installing vscode (Default for non-interactive setups is true).
If they already have to current Microsoft repo enabled (checked using apt-cache policy), it won't be added. This helps with upgrades to Ubuntu 24.04, since all .list files are converted to the .sources format and then added again by vscode, causing apt to complain about duplicate sources.
If the postinst is not sure about whether the user wants the sources or not, the user gets the option to confirm whether they want the sources to be installed.

@Tyriar Tyriar reopened this Jul 9, 2024
@Tyriar Tyriar assigned rzhao271 and unassigned Tyriar Jul 9, 2024
@Tyriar Tyriar removed the *out-of-scope Posted issue is not in scope of VS Code label Jul 9, 2024
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Aug 1, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Aug 1, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Aug 1, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
m-byte added a commit to VOGL-electronic/vscode that referenced this issue Aug 6, 2024
Currently, vscode.list is added to /etc/apt/sources.d/ whenever it
doesn't exist. With this patch, the new behaviour is as follows:

1. If the user already has the Microsoft source file installed for apt,
   sources won't be added
2. If the user sets debconf-set-selections to set code/add-microsoft-repo
   to false, the sources won't be added
3. If sources might be added, the script checks whether it makes sense to
   (over)write them (i.e. the file doesn't exist, is old or has been disabled
   during some OS upgrade)
4. If is makes sense and the code/add-microsoft-repo is not set, the user is
   asked to cofirm, whether they actually want Microsoft sources to be
   installed (setting code/add-microsoft-repo to the selected value)
5. Only if it makes sense and the user agrees, the sources are installed

This change will mostly affect new users or those reinstalling vscode.
Personally, I feel like the whole approach of automatically adding the
repo is very invasive, and would prefer that it not be done at all.
However, with this change, it is up to the user whether they want it
to be installed or not. Since the default is set to true, users that
install vscode in noninteractive environments get the current behavior.
Existing users will either be asked once or never (depending on whther
step 4 above gets triggered). New users will be asked unless they make
a decision ahead of time using debconf-set-selections.

With this, microsoft#22145 and duplicates should be sufficiently addressed.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
@Tyriar Tyriar modified the milestones: Backlog, August 2024 Aug 6, 2024
rzhao271 pushed a commit that referenced this issue Aug 6, 2024
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
@rzhao271
Copy link
Contributor

\closedWith cd340e6

@vs-code-engineering vs-code-engineering bot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Aug 26, 2024
@rzhao271 rzhao271 added the on-release-notes Issue/pull request mentioned in release notes label Aug 29, 2024
@Tyriar
Copy link
Member

Tyriar commented Sep 6, 2024

Reopening because of #221285 (comment)

@Tyriar Tyriar reopened this Sep 6, 2024
@Tyriar Tyriar modified the milestones: August 2024, September 2024 Sep 6, 2024
@vs-code-engineering vs-code-engineering bot removed the insiders-released Patch has been released in VS Code Insiders label Sep 6, 2024
@rzhao271 rzhao271 linked a pull request Sep 6, 2024 that will close this issue
@rzhao271 rzhao271 modified the milestones: September 2024, October 2024 Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities install-update VS Code installation and upgrade system issues linux Issues with VS Code on Linux on-release-notes Issue/pull request mentioned in release notes on-testplan
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants