Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 76417

Summary: [Import/Export] Import existing project wizard doesn't allow to import a project from the workspace
Product: [Eclipse Project] Platform Reporter: Panagiotis Korros <panagiotis.korros>
Component: UIAssignee: Karice McIntyre <Karice_McIntyre>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P4 CC: java97301, matt.doran, ms, nikolaymetchev, osullivanro, sennsafe-devsites
Version: 3.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Panagiotis Korros CLA 2004-10-16 04:01:01 EDT
There are many times that I create/checkout a new project in the workspace area
(c:\projects) and I want to import it to the eclipse workspace.

Currently the import wizard can import some projects but it has a problem
importing others reporting that the project overlaps with the workspace.
(Why is that?)

As stated in https://bugs.eclipse.org/bugs/show_bug.cgi?id=49192#c10 a
workaround is to create a project with the same name, using the new project
wizard, but this is inconvinient.

In the case where the Project name is different than the folder name then you
can't import it at all (try it out).
Comment 1 DJ Houghton CLA 2004-10-18 14:32:17 EDT
I believe this would require the Project Import Wizard to know whether or not
the user-entered location is the same as the default location.
Comment 2 Tod Creasey CLA 2004-10-19 08:07:09 EDT
You can also just do this by creating  new project and pointing to its 
location in the location field.
Comment 3 Panagiotis Korros CLA 2004-10-19 08:49:12 EDT
As I said in my initial comment, creating a project is not allways a solution.
If the workspace is located at c:\Projects and you want to import the
c:\Projects\test project with a different name then you can't do it at all.
The creation wizard informs you that you can't create a project into the
workspace area (the message is 'Project contents cannot be in the workspace
directory').
Comment 4 Panagiotis Korros CLA 2004-10-19 08:50:00 EDT
I think that the severity of this issue is MAJOR and should be given higher
priority than P5.

A new/inexperienced eclipse user will NEVER think of creating a new project.
The first time it happened to me, I didn't know hot to solve this problem and
creating a new project never came in my mind.
I don't think that any eclipse user will think of creating a new project instead
because 'project creation' doesn't have the same semantics with an 'import
project' operation.
Comment 5 Tod Creasey CLA 2004-10-19 10:40:49 EDT
Upping priority as requested. The reason it is currently implemented this way 
is that you are not importing really , your are restoring. Of course new is 
does not mean restore either so I don't think that is necessarily a reason to 
disallow it.

If you have a suggested patch please apply it to the bug.
Comment 6 Panagiotis Korros CLA 2004-10-20 18:08:36 EDT
I think I found was is causing the problem and why this problem appears in some
projects only.

My project workspace is c:\Projects,
the project I want to import is located at c:\Projects\test
but the .project file contains a different name for the project.

The call to getWorkspace().loadProjectDescription(path) in
WizardExternalProjectImportPage.setProjectName returns a descriptor with
name: org.tigris.subversion.subclipse.test
location: c:\Projects\test
and the project creation fails because c:\Projects\test is not the default
location but overllaps with the workspace.

If I change the name in the .project file, everything works correctly but this
isn't a workaround.

Is there a way to load the project from the fefault location but use a different
name?
Comment 7 Matt Doran CLA 2004-10-21 07:57:07 EDT
I just encountered exactly the same issue and came to the same conclusion (after
a couple of painful hours investigation), and was about to raise the issue.  If
you try to import a project that's in the workspace, the "name" in the .project
file must match the directory name exactly.  

If it differs then you get the unhelpful error message "invalid project
description" and detailed message about overlapping that doesn't make much sense.

In the very least the error message should be clearer.  But given that you can
rename the project to anything once imported, then there isn't any reason why
importing like this shouldn't work.
Comment 8 Tod Creasey CLA 2004-10-21 08:15:07 EDT
The project name has to match the name of the folder it is created in if it is 
under the workbench directory - this is a restriction of Core.
Comment 9 Marko Schulz CLA 2004-11-19 16:25:18 EST
Just like Matt Doran, I encountered exactly the same issue and it took
me some hours to figure out what the problem was.

Here was my use case: Some time ago, I had created a number of
projects outside the workspace directory. Some projects had the same
name as the directory they resided in, some not. Some had in the
beginning, but renaming a project outside of the workspace directory
only changes its name, not the directory it lives in.

Switching to Eclipse 3.1M3 I wanted to clean up my project structures,
so I started of with a fresh workspace and moved - outside of eclipse,
literally the files - the project directories into the workspace
directory. Within Eclipse I imported the projects one after the
other. For some time I couldn't figure out, why some imports failed
with the strange message "Invalid project description" (Details:
"$projectDir and $workspaceDir overlap."). I looked at the .project
files and everything looked OK. 

After some poking around I finally found bug 39343, where someone
describes the same problem using CDT, and this bug report. With the
tiny, additional information that I just have to rename the directory,
everything went fine.

So, please, for users at least make the wizard detect the special
situation and give a more meaningful error message. Of course it would
be even better, if the wizard would offer to solve the problem for the
user ("Should I ( ) rename the project, or ( ) rename the
directory?"). 

Best would be if eclipse could simply handle the case of projects
which have their files in an directory in the workspace directory
where project name and directory name differ. But if this is an
restriction of Core, which will not change soon: OK, just use on of
the little bit inferior solutions from above. 

Thanks
Comment 10 Tod Creasey CLA 2005-04-11 17:03:34 EDT
*** Bug 90695 has been marked as a duplicate of this bug. ***
Comment 11 Roan CLA 2005-12-22 11:41:14 EST
Another case where this comes up -- if you create a new workspace where a set of projects already exist (for example: moving some sandbox projects under a new "sandbox" workspace to make way for real work). 

Since the workspace is not so much a physical location as a user Profile, this bug leads to confusion for a new user (not to mention the name "workspace" is misleading).
Comment 12 Will Senn CLA 2006-06-27 11:09:13 EDT
The original comment on this bug was almost two years ago... Today, I spent a couple of hours riddling this out before I found this report. When is it going to be fixed?

I'm using Version: 3.1.2 Build id: M20060118-1600

There is no way that the error message will lead anyone to discover that the name of the directory has to match the <name> element in the .project file.

Even after learning this, I had to scratch my head a few times before I realized that I had misspelled the directory name BlahEndoder instead of BlahEncoder in the first place :)

The error message should state something more meaningful, maybe somehting to the effect:
"Project name does not match project folder name"

Comment 13 Karice McIntyre CLA 2006-06-28 16:04:39 EDT
The fix for bug 143757 (which was just released into the 3.3 code stream) allows you to import a project whose folder does not match the project name in the .project file.

*** This bug has been marked as a duplicate of 143757 ***