Eclipse 更新后丢失的可用软件站点列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23379111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:41:31  来源:igfitidea点击:

List of available software sites lost after Eclipse update

eclipse

提问by stenci

After clicking the Check Update, installing a few updates and clicking OK to restart Eclipse, the list of available software sites in the Install window is gone.

单击“检查更新”、安装一些更新并单击“确定”以重新启动 Eclipse 后,“安装”窗口中的可用软件站点列表消失了。

Is it possible to get it as it was?

有可能得到它吗?

If not, how can I rebuild it so that my plug-ins will be updated in the future?

如果没有,我如何重建它以便将来更新我的插件?

I'm working with Eclipse 4.3.2 in Windows 7.

我正在 Windows 7 中使用 Eclipse 4.3.2。

回答by Geesz

I ran into the same problem on a Win7-64bit after a set of automatic updates. All settings for "Available Software Sites" were lost. My eclipse version after the data lost was luna 4.4.2. (don't now the version number before, I had installed eclipse-cpp-luna-SR1a-win32-x86_64_2014.zip).

在一组自动更新后,我在 Win7-64 位上遇到了同样的问题。“可用软件站点”的所有设置都丢失了。数据丢失后我的eclipse版本是luna 4.4.2。(不要现在的版本号之前,我已经安装了eclipse-cpp-luna-SR1a-win32-x86_64_2014.zip)。

I set this site to get the "/Help/Install new software...." Dialog work again:

我设置此站点以获取“/Help/Install new software....”对话框再次工作:

Eclipse-Project-Repository - http://download.eclipse.org/eclipse/updates/4.4

Eclipse-Project-Repository - http://download.eclipse.org/eclipse/updates/4.4

To get the repository for another eclipse version look here. Follow the link to your eclipse version and search there for the "Eclipse p2 Repository".

要获取另一个 Eclipse 版本的存储库,请查看此处。按照指向您的 eclipse 版本的链接并在那里搜索“Eclipse p2 Repository”。

回答by NoDataFound

For those interested in restoring the update site, here is a way to do the job which may or may not work for you:

对于那些有兴趣恢复更新站点的人,这里有一种方法可以完成这项工作,可能适合您,也可能不适合您:

  • Locate the ${ECLIPSE_HOME}\p2\org.eclipse.equinox.p2.engine\profileRegistry\<profile>\.data\.settings\org.eclipse.equinox.p2.artifact.repository.prefsfile. The <profile>depends on the installed Eclipse, for me it was epp.package.rcp.profile.
  • Find all keys ending by /uri=: they would contains the original URI. You could use grep: grep --color -Po '/uri=.+' org.eclipse.equinox.p2.artifact.repository.prefs(you may want to filter file:/URI).
  • Remove the /uriand unescape the property to regain valid URI: sedis good for that. eg: sed -E -e 's@^/uri=@@g' -e 's@\\@@g'
  • Apply a sort --unique
  • 找到该${ECLIPSE_HOME}\p2\org.eclipse.equinox.p2.engine\profileRegistry\<profile>\.data\.settings\org.eclipse.equinox.p2.artifact.repository.prefs文件。这<profile>取决于安装的 Eclipse,对我来说它是epp.package.rcp.profile.
  • 查找以/uri=:结尾的所有键,它们将包含原始 URI。您可以使用 grep:(grep --color -Po '/uri=.+' org.eclipse.equinox.p2.artifact.repository.prefs您可能想要过滤file:/URI)。
  • 删除/uri并取消转义属性以重新获得有效的 URI:sed对此有好处。例如:sed -E -e 's@^/uri=@@g' -e 's@\\@@g'
  • 申请一个 sort --unique

Now, you would have this command line and result:

现在,您将拥有此命令行和结果:

$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs | sed -E -e 's@^/uri=@@g' -e 's@\@@g' | sort
https://spotbugs.github.io/eclipse/
http://download.eclipse.org/e4/snapshots/org.eclipse.e4.tools/latest/
http://download.eclipse.org/eclipse/updates/4.7
http://download.eclipse.org/eclipse/updates/4.7/R-4.7-201706120950
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.1-201709061700
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.1a-201710090410
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.2-201711300510
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.3-201803010715
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.3a-201803300640

You are almost there!

你快到了!

If you look at the example above, you can see multiple duplicate URI for the same endpoint (/eclipse/updates/4.7) which is a P2 composite repository: you may add it to the sed command to remove these parts: -e 's@/(R-[^/]+|)20[0-9]{10}@@g'.

如果您查看上面的示例,您可以看到同一端点 ( /eclipse/updates/4.7) 的多个重复 URI,它是 P2 复合存储库:您可以将其添加到 sed 命令以删除这些部分:-e 's@/(R-[^/]+|)20[0-9]{10}@@g'.

That's better:

这样更好:

$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs | sed -E -e 's@^/uri=@@g' -e 's@\@@g' -e 's@/(R-[^/]+|)20[0-9]{10}@@g' | sort --unique
http://download.eclipse.org/e4/snapshots/org.eclipse.e4.tools/latest/
http://download.eclipse.org/eclipse/updates/4.7
http://download.eclipse.org/efxclipse/updates-released/3.0.0/site
http://download.eclipse.org/releases/oxygen
http://download.eclipse.org/technology/epp/packages/oxygen/
http://eclipse.pitest.org/release/
http://netceteragroup.github.io/quickrex/updatesite
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/0.8.0.201409231215/
http://ucdetector.sourceforge.net/update/

Now we will transform that into a XML file to be imported: in the Available Software Sites, you may export a bookmarks.xmlfile which contains this for one entry:

现在我们将把它转换成一个要导入的 XML 文件:在可用软件站点中,您可以导出一个bookmarks.xml文件,其中包含一个条目:

<?xml version="1.0" encoding="UTF-8"?>
<bookmarks>
   <site url="http://download.eclipse.org/eclipse/updates/4.7" selected="true" name=""/>
</bookmarks>

As you would probably don't care about the nameor selected(Eclipse may also update these using the Update site metadata), you may use builtin or sedagain:

由于您可能不关心nameselected(Eclipse 也可能使用更新站点元数据更新这些),您可以使用内置或sed再次:

$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs.old | \
  sed -E -e 's@^/uri=@@g' -e 's@\@@g' -e 's@/(R-[^/]+|)20[0-9]{10}@@g' | \
  sort --unique | \
  while read url; do echo "<site url=\"${url}\" />"; done > bookmarks.xml

You now have a bookmarks.xmlto edit: simply add the <?xml version="1.0" encoding="UTF-8"?> <bookmarks>and </bookmarks>, and import it in Available Software Suite.

您现在可以bookmarks.xml进行编辑:只需添加<?xml version="1.0" encoding="UTF-8"?> <bookmarks></bookmarks>,然后将其导入到可用软件套件中

All that remains is to enable all siteby selecting them and clicking Enable. When done, try to update Eclipse as usual and that should do the job!

剩下的就是通过选择它们并单击启用启用所有站点。完成后,尝试像往常一样更新 Eclipse,这应该可以完成工作!

You may want to:

您可能想要:

  • Remove any invalid entries or at least disable them
  • Save your bookmarks.xmlinto a repository or "somewhere".
  • Export the bookmarks.xmlagain, now with proper name.
  • 删除任何无效条目或至少禁用它们
  • 将您的内容保存bookmarks.xml到存储库或“某处”。
  • bookmarks.xml再次导出,现在使用正确的名称。

Good luck!

祝你好运!

And ... raise this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=502524

并且……提出这个错误报告:https: //bugs.eclipse.org/bugs/show_bug.cgi?id=502524

回答by Edison Valentim Lopes

I ran into the same problem on a Win10-64bit after a set of automatic updates. All settings for "Available Software Sites" were lost. Eclipse p2 Repository
To update your Eclipse installation to this development stream, you can use the software repository at http://download.eclipse.org/eclipse/updates/4.5. To update your build to use this specific build, you can use the software repository at http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500

在一组自动更新后,我在 Win10-64 位上遇到了同样的问题。“可用软件站点”的所有设置都丢失了。Eclipse p2 存储库
要将 Eclipse 安装更新到此开发流,您可以使用位于http://download.eclipse.org/eclipse/updates/4.5的软件存储库 。要更新您的构建以使用此特定构建,您可以使用位于http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500的软件存储库

回答by Tanya

Fixed in Neon

固定在霓虹灯

Good new is that the available update sites survive Eclipse update on Neon. But I still see this problem on Mars and older.

好消息是可用的更新站点在 Neon 上的 Eclipse 更新中幸免于难。但我仍然在火星和更老的地方看到这个问题。

Fix for Mars and older releases

修复 Mars 和旧版本

There is a simple change which fixed this problem for me on Mars-, it's adding the "-Djava.net.preferIPv4Stack=true" JVM param to Eclipse.inifile beforerunning an update:

在 Mars 上有一个简单的更改为我解决了这个问题,它运行更新之前将“-Djava.net.preferIPv4Stack=true” JVM 参数添加到 Eclipse.ini文件中:

-Djava.net.preferIPv4Stack=true

Please note this is a VM argument, so it must go after the "-vmargs"

请注意这是一个 VM 参数,因此它必须在“-vmargs”之后

So why the available software sites were deleted on update?

那么为什么可用的软件站点在更新时被删除呢?

Eclipse Update is done by ProvisioningJob which calls LoadMetadataRepositoryJob.runModal(), which in its turn calls MetadataRepositoryManager.loadRepository().

Eclipse 更新由 ProvisioningJob 完成,它调用 LoadMetadataRepositoryJob.runModal(),后者又调用 MetadataRepositoryManager.loadRepository()。

AbstractRepositoryManager.loadRepository() checks if a repository is valid by callingcheckNotFound(). If it's not found that the repo is not added. preferIPv4=true fixes it.

AbstractRepositoryManager.loadRepository() 通过调用checkNotFound() 检查存储库是否有效。如果没有找到,则不添加 repo。优选IPv4=true 修复它。

回答by Christoph

I encountered this with Eclipse 4.16 (2020-06).

我在 Eclipse 4.16 (2020-06) 中遇到了这个问题。

Inspired by @NoDataFound approach, I wrote a Perl script as an all-in-one-solution.

受@NoDataFound 方法的启发,我编写了一个 Perl 脚本作为一体化解决方案。

How it works:

这个怎么运作:

  • Check each line of '/p2/org.eclipse.equinox.p2.engine/profileRegistry//.data/.settings/org.eclipse.equinox.p2.artifact.repository.prefs' for 'nickname', 'uri' or 'enabled' of a http[s] repo.
    Store captured property name and value in a hash associated with the repo identifier.

    my $propNameCapture = qr/(nickname(?==.*)|(?:uri|enabled)(?==.+))/;
    my ($repo, $propName) = m{^repositories/(http.+?)/$propNameCapture};
    next if !$repo || !$propName;
    
    my ($propValue) = m{^repositories/http.+?/$propName=(.*)};
    
    # Remove the backslash after http[s] if we have an uri.
    $propValue =~ s/\// if $propName eq 'uri';
    
    # $repo is used merely to collect props belonging together.
    $SiteFromRepo{$repo}->{$propName} = $propValue;
    
  • Create an array of site properties

    for my $site (values %SiteFromRepo)
    {
        # There are many entries without a nickname.
        # These are not from "Available Software Sites", so skip them.
        next unless exists $site->{nickname};
    
        print("nickname:\t$site->{nickname}\nuri:\t\t$site->{uri}\nenabled:\t$site->{enabled}\n\n");
    
        push(@Sites, $site);
    }
    
  • Write XML file

    open($fh, '>:utf8', $OutFilePath) or die("Could not open file '$OutFilePath' for write, exiting.\n");
    
    $fh->print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bookmarks>\n");
    $fh->print("   <site url=\"$_->{uri}\" selected=\"$_->{enabled}\" name=\"$_->{nickname}\"/>\n") for @Sites;
    $fh->print('</bookmarks>');
    
    close($fh);
    
  • 检查'/p2/org.eclipse.equinox.p2.engine/profileRegistry//.data/.settings/org.eclipse.equinox.p2.artifact.repository.prefs'的每一行'nickname'、'uri'或http[s] 存储库的“启用”。
    将捕获的属性名称和值存储在与 repo 标识符关联的哈希中。

    my $propNameCapture = qr/(nickname(?==.*)|(?:uri|enabled)(?==.+))/;
    my ($repo, $propName) = m{^repositories/(http.+?)/$propNameCapture};
    next if !$repo || !$propName;
    
    my ($propValue) = m{^repositories/http.+?/$propName=(.*)};
    
    # Remove the backslash after http[s] if we have an uri.
    $propValue =~ s/\// if $propName eq 'uri';
    
    # $repo is used merely to collect props belonging together.
    $SiteFromRepo{$repo}->{$propName} = $propValue;
    
  • 创建一组站点属性

    for my $site (values %SiteFromRepo)
    {
        # There are many entries without a nickname.
        # These are not from "Available Software Sites", so skip them.
        next unless exists $site->{nickname};
    
        print("nickname:\t$site->{nickname}\nuri:\t\t$site->{uri}\nenabled:\t$site->{enabled}\n\n");
    
        push(@Sites, $site);
    }
    
  • 写入 XML 文件

    open($fh, '>:utf8', $OutFilePath) or die("Could not open file '$OutFilePath' for write, exiting.\n");
    
    $fh->print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bookmarks>\n");
    $fh->print("   <site url=\"$_->{uri}\" selected=\"$_->{enabled}\" name=\"$_->{nickname}\"/>\n") for @Sites;
    $fh->print('</bookmarks>');
    
    close($fh);
    

The complete script can be downloaded from my GitHub repo

完整的脚本可以从我的 GitHub repo下载

回答by JCT

Try to run Eclipse as administrator. That way the "check for updates" should work.

尝试以管理员身份运行 Eclipse。这样“检查更新”应该可以工作。