[SOLVED] Changes in one project influences another project lazarus / 62-General ---------------------------------------------------------------------- yurkad · 2017-03-17 12:15 Hello! Windows XP, Lazarus 1.6.0 In some folder I have folders folder1 and folder2. Folder folder1 has laz1.lpi project and folder folder2 has laz2.lpi project.   Folder       folder1           laz1.lpi       folder2           laz2.lpi Both projects are very similar and contains almost equal names of units. After I add some unit in Code edit window of laz1.lpi then close laz1.lpi and open laz2.lpi,  this unit will appear in code edit window of laz2.lpi too. Same with delete some unit from laz1.lpi or from laz2.lpi. The real names of  laz1.lpi and  laz2.lpi are the same. Can be avoided this? Thanks ---------------------------------------------------------------------- JuhaManninen · 2017-03-17 13:32 Your projects refer to each other somehow. Maybe the other project's folder is in the search path of the other one and you edit a wrong file. See the file's location in editor statusbar. You also could have inherited a form somehow from another form. Check the unit search paths of both projects. ---------------------------------------------------------------------- yurkad · 2017-03-17 13:42 Each project has reference to same packs. Sorry, but I do not know what is "unit search paths" in your answer. ---------------------------------------------------------------------- yurkad · 2017-03-17 14:11 Perhaps "paths" is this: http://wiki.freepascal.org/images/2/21/CompilerOptions-Paths.png These paths are the same in both my projects. ---------------------------------------------------------------------- yurkad · 2017-03-17 14:22 I changed path of folder for search strings in files in laz1.lpi. But then in laz2.lpi this path was changed too. ---------------------------------------------------------------------- Handoko · 2017-03-17 14:39 Maybe the projects are using unit files that come from same location. Please see the image I provide. Note: I use Linux so the path separator is different with Windows. To show up the Project Inspector: Lazarus main menu > Project > Project Inspector. On my example, you can see there are 2 units (unidebug and unifile) that are come from other folder. You can know it because the path are started with ".." (2 dots). It means the units are not placed on the project's folder. Using unit file that is not placed on the project folder can be tricky (except the units that come from installed packages). I have to do it because several of my projects need those same units. But as I said it is tricky, I frequently messed up the codes. Until I was familiar with them, now I am careful enough not to cause problem. So, maybe you can check your project inspector to make sure they aren't using any of unit that from other folder. ---------------------------------------------------------------------- bylaardt · 2017-03-17 15:21 arbitrary paths in fpc.cfg? -Fu -Fi -Fl? ---------------------------------------------------------------------- yurkad · 2017-03-17 15:38 bylaardt, thank by answer I am sorry, but I do not have enough knowledge for understand it. Perhaps you're right. ---------------------------------------------------------------------- yurkad · 2017-03-17 15:53 Handoko, thanks by detailed and clear explanation. I understood it. Thank by image too. In Project Inspector there is no some path. Only names. In both projects. I made following experiment: Added new folder folder3 thus:   Folder    ...folder1    ......laz1.lpi    ...folder2    ......laz2.lpi   Folder3 Then renamed folders folder1 y folder2 thus:   Folder    ...folder11    ......laz1.lpi    ...folder21    ......laz2.lpi   Folder3 Then put all content of folder21 to folder Folder3 (for avoid [..]) So finally I have following:   Folder    ...folder11    ......laz1.lpi    ...folder21    ......laz2.lpi   Folder3   ...laz2.lpi I am thinking, that this structure breaks any type of references between both projects. Here are results: 1. Compilation of folder11 was good. So I think, that laz1.lpi from folder11 have not dependences with laz2.lpi of Folder3. 2. Compilation of folder3 was good. So I think, that laz2.lpi from folder3 have not dependences with laz1.lpi of Folder11. 3. The problem (between  laz1.lpi from folder11 and  laz2.lpi from folder3 ) persists. Again: Each project has same Required Packages and same own name. ---------------------------------------------------------------------- Handoko · 2017-03-17 16:20 Halo, after some inspections I now found something that maybe the cause of your problem. Try to open your project file but use only notepad (or wordpad). There you can see the filename is mentioned in the *.lpi file. For example, my project file is project1.lpi. In that files, it has this line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         I guess you're thinking what I think. Simply renaming the project file is not enough. Inside the file, the file name is hardcoded, you need to manually edit it too. ---------------------------------------------------------------------- yurkad · 2017-03-17 20:42 Thanks, Handoko. Yes, I can see this line by using of wordpad. What I must make with .lpi file? I did not change name of project. I did change only folder names. ******************** Here is another question. I can open laz2.lpi with wordpad and edit list of units. By sample I delete two last blocks ... and ... .  After this I save wordpad and open laz2.lpi as Lazarus project. And I see that nothing changed. By other words the changes in laz2.lpi have no effect (within limits). And other thing:  Editor Window does not show several units. By in laz2.lpi they esists. Clarify: After add/delete units by using of Editor Window the file  laz2.lpi has changes corresponding. But simple by open and close laz1.lpi and open laz2.lpi the content of units in project laz2.lpi does not corresponding to content of units of file laz2.lpi. ---------------------------------------------------------------------- JuhaManninen · 2017-03-17 21:26 yurkad, you do things in a very difficult way. If you create new projects using the IDE as you are supposed to do, there will be no such problems. You should use your capacity for real programming challenges instead of such self-made useless problems. ---------------------------------------------------------------------- yurkad · 2017-03-17 21:43 yurkad, you do things in a very difficult way. You are absolutely right. If you create new projects using the IDE as you are supposed to do, there will be no such problems. You should use your capacity for real programming challenges instead of such self-made useless problems. It is very good advice. I wanted to help find some bug. But now taking into account that you are Global Moderator and Hero Member I will fulfill your advice. Thanks. ********************************* Please, this page is closed. ---------------------------------------------------------------------- JuhaManninen · 2017-03-18 10:26 Quote from: yurkad on March 17, 2017, 10:43:19 pmI wanted to help find some bug. Ok, if there is a bug then I misunderstood you. My impression was that you had copied the project files in a way they are not meant to be copied, resulting wrong references somewhere. Copying source code between projects in editor is rather safe, as well as copying a Pascal unit file. Copying the project files is different and not recommended. Anyway, if there is bug then we need clear steps to reproduce it. One more thing about Lazarus projects and packages (this whole thread should be in Lazarus section): Project's unit search path (-FU) should not point to external shared code. For shared code you should always create a Lazarus package! This is different from Delphi. There packages have their paths added to a global search path, used by all projects. It pollutes the namespace also for projects that don't use a certain package. In Lazarus a project gets a dependency for a package. The package is found even if it is not installed in IDE because its location is remembered after it is opened once in the IDE. ---------------------------------------------------------------------- yurkad · 2017-03-18 21:52 Ok. Thanks by good explanation, JuhaManninen. ---------------------------------------------------------------------- Martin_fr · 2017-03-18 23:13 Rereading your post: QuoteAfter I add some unit in Code edit window of laz1.lpi then close laz1.lpi and open laz2.lpi,  this unit will appear in code edit window of laz2.lpi too. Same with delete some unit from laz1.lpi or from laz2.lpi. Is this about units OPEN in the EDITOR window? Because that differs from "ADDED to PROJECT". Did you actually test, if the IDE modifies the lpi in the "other" directory? - Backup both lpi - work on one project - save and close. - use a diff tool to see if the other lpi was modified. ------------------------ The windows open in the editor, are stored in the session (and you can open files, that do NOT belong to the project, yet will be remembered). The session can be stored either: - as part of the lpi - as lps file in the project folder - as lps file in the global lazarus conf dir (primary config path) And in the last case, if both projects have the same name, that will mean they share a session. Go to menu: Project > Project Options then page: Project Options > Session And it will show where your session goes. ---------------------------------------------------------------------- Martin_fr · 2017-03-18 23:16 Off topic / but about copying projects Most of the time coping the folder will work. A better way to get a clean copy, is using "Publish project" from the menu. ---------------------------------------------------------------------- Handoko · 2017-03-19 01:57 Something that yurkat said interest me: QuoteThe real names of  laz1.lpi and  laz2.lpi are the same. That makes me think of an issue that I ever made. I ever copied/pasted a project and renamed the copied project file (.lpi) manually (all those things done using file manager). Then weird things happened. Lesson learned, so if I want to duplicate project to a new name, now I always use: Lazarus main menu > Project > Save Project As I guess yurkad's issue is the same as the thing I did. ---------------------------------------------------------------------- yurkad · 2017-03-19 21:47 Martin_fr, thanks! QuoteIs this about units OPEN in the EDITOR window?Yes, it is QuoteBecause that differs from "ADDED to PROJECT".Yes, it is thus. QuoteDid you actually test, if the IDE modifies the lpi in the "other" directory?I did not understand this. Quote- Backup both lpi - work on one project - save and close. - use a diff tool to see if the other lpi was modified.Sorry, but I cannot make this already. According of advice of JuhaManninen I made new project, which is working correctly and then I deleted both folders. QuoteThe windows open in the editor, are stored in the session (and you can open files, that do NOT belong to the project, yet will be remembered). The session can be stored either: - as part of the lpi - as lps file in the project folder - as lps file in the global lazarus conf dir (primary config path) And in the last case, if both projects have the same name, that will mean they share a session.It is very useful information. I deleted  lps file in the project folder. By this my case is:Quote lps file in the global lazarus conf dir (primary config path)Unfortunately I did not know about the existence of this file in the global lazarus conf dir. So the cause of this problem was that both projects share a session thru lps file in the global lazarus conf dir. Thank you again, Martin_fr. The problem is solved! QuoteGo to menu: Project > Project Options then page: Project Options > Session And it will show where your session goes.I acknowledge that the real cause of this problem was my irresponsibility for using Lazarus. I should have studied so many things before, how to use it correctly! Including about session. QuoteOff topic / but about copying projects Most of the time coping the folder will work. A better way to get a clean copy, is using "Publish project" from the menu.This is the key advice to duplicate project in Lazarus. Many thanks! ---------------------------------------------------------------------- yurkad · 2017-03-19 21:58 Thank you, Handoko. I hope that my previous post can be answer for you also. ---------------------------------------------------------------------- yurkad · 2017-03-19 22:08 The problem definirively is solved. I apologize to all who wrote in this page and to all who read it. You lost so much time just because I did not fulfill an obvious rule: Before using a thing you have to study the rules of how to use it correctly.