[Sugar-devel] "Another osbuild instance is running" error

James Cameron quozl at laptop.org
Sat Jan 2 05:31:37 EST 2016


On Sat, Jan 02, 2016 at 12:30:25PM +0530, Shraddha Barke wrote:
> 
> 
> On Sat, 2 Jan 2016, James Cameron wrote:
> 
> >On Sat, Jan 02, 2016 at 10:21:12AM +0530, Shraddha Barke wrote:
> >>
> >>
> >>On Sat, 2 Jan 2016, James Cameron wrote:
> >>
> >>>On Fri, Jan 01, 2016 at 08:38:34PM +0530, Shraddha Barke wrote:
> >>>>
> >>>>
> >>>>On Fri, 1 Jan 2016, James Cameron wrote:
> >>>>
> >>>>>On Thu, Dec 31, 2015 at 11:26:26PM +0530, Shraddha Barke wrote:
> >>>>>>
> >>>>>>
> >>>>>>On Thu, 31 Dec 2015, James Cameron wrote:
> >>>>>>
> >>>>>>>On Thu, Dec 31, 2015 at 03:38:02AM +0530, Shraddha Barke wrote:
> >>>>>>>>>On Wed, Dec 30, 2015 at 04:30:17AM +0530, Shraddha Barke wrote:
> >>>>>>>>>>I am trying to build sugar on Ubuntu 15.04 laptop. After git clone
> >>>>>>>>>>and cd into sugar-build I get this error-Another osbuild instance is
> >>>>>>>>>>running on executing ./osbuild pull
> >>>>>>>>>>I searched the internet and found 2 such threads but the issue wasn't
> >>>>>>>>>>resolved.
> >>>>>>>>>
> >>>>>>>>>There's more than two such threads on sugar-devel at .
> >>>>>>>>>
> >>>>>>>>>>Is this a bug that needs fixing?
> >>>>>>>>>
> >>>>>>>>>Yes, it's a bug in osbuild, please fix it.
> >>>>>>>>
> >>>>>>Hello James,
> >>>>>>I made the following changes in check_lock()
> >>>>>>
> >>>>>>def check_lock():
> >>>>>>-    try:
> >>>>>>-        fcntl.lockf(get_lock_file(), fcntl.LOCK_EX | fcntl.LOCK_NB)
> >>>>>>-    except IOError:
> >>>>>>-        return False
> >>>>>>-
> >>>>>>-    return True
> >>>>>>-
> >>>>>>
> >>>>>>+       pid = os.getpid()
> >>>>>>+       try:
> >>>>>>+            fcntl.lockf(pid, fcntl.LOCK_EX | fcntl.LOCK_NB)
> >>>>>>+       except IOError:
> >>>>>>+           return False
> >>>>>>+       try:
> >>>>>>+           os.kill(pid(), 0)
> >>>>>>+       except OSError:
> >>>>>>+            return False
> >>>>>>+        return True
> >>>>>
> >>>>>Ah, that's not what I meant.
> >>>>>
> >>>>>But I was wrong to suggest a redesign using getpid and kill, because
> >>>>>my analysis of the code _today_ shows the underlying cause must be
> >>>>>something other than locking.
> >>>>>
> >>>>>Let me explain.
> >>>>>
> >>>>>check_lock does try fcntl.lock, and if an exception IOError occurs,
> >>>>>does return False.
> >>>>>
> >>>>>But inside the same try clause is a call to get_lock_file.  Therefore
> >>>>>any IOError inside get_lock_file will also cause check_lock to return
> >>>>>False.
> >>>>>
> >>>>>A possible error is that the file could not be opened for write,
> >>>>>e.g. because it is owned by someone else, or the protection mask
> >>>>>(chmod) is wrong, or the directory does not exist, or the directory is
> >>>>>protected.
> >>>>>
> >>>>>def check_lock():
> >>>>> lock_file = get_lock_file()
> >>>>> try:
> >>>>>     fcntl.lockf(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB)
> >>>>> except IOError:
> >>>>>     return False
> >>>>>
> >>>>> return True
> >>>>>
> >>>>>As a result of this change, any problem opening and writing to the
> >>>>>file will be reported before the "another instance" error.
> >>>>>
> >>>>
> >>>>Ah Got it! Thanks :)
> >>>>
> >>>>Like you said it's a permission error. I've posted it below -
> >>>>
> >>>>Traceback (most recent call last):
> >>>> File "./osbuild", line 504, in <module>
> >>>>   if not main():
> >>>> File "./osbuild", line 467, in main
> >>>>   if not check_lock():
> >>>> File "./osbuild", line 406, in check_lock
> >>>>   lock_file = get_lock_file()
> >>>> File "./osbuild", line 90, in get_lock_file
> >>>>   lock_file = open(get_lock_file_path(), "w")
> >>>>IOError: [Errno 13] Permission denied:
> >>>>'/home/shraddha/git/sugar-build/.lock-host'
> >>>
> >>>Okay, that will certainly stop osbuild from working.
> >>>
> >>>>
> >>>>>>
> >>>>>>so that when there is no process running false is returned. However it is
> >>>>>>not fixing the bug.
> >>>>>>And yeah when I try to delete the lock file, I get 'file or
> >>>>>>directory doesn't exist'
> >>>>>
> >>>>>That's not possible to explain given the data you sent.
> >>>>>
> >>>>>You said the print statement showed the file path as
> >>>>>
> >>>>>.../git/sugar-build/.lock-host
> >>>>>
> >>>>>Presumably ... is something like /home/username
> >>>>>
> >>>>>Does the .lock-host file still exist?
> >>>>>
> >>>>>Show me "stat .lock-host"?
> >>>>>
> >>>>>If the file exists, but you cannot delete it, then osbuild will fail
> >>>>>to open it for write.
> >>>>>
> >>>>
> >>>>stat: cannot stat ‘.lock-host’: No such file or directory
> >>>>
> >>>>This is what I get. It's confusing that although it's failing to write,
> >>>>stat says no such directory exists!
> >>>
> >>>Ye, that is strange.  On the one hand the file exists and cannot be
> >>>opened for write, yet now the file does not exist.
> >>>
> >>>Please check you are in the right directory when you use stat, or use
> >>>stat with the same full path to the file (as reported by osbuild);
> >>>
> >>>	stat /home/shraddha/git/sugar-build/.lock-host
> >>>
> >>>I'm trying not to presume any knowledge; if you only type "stat
> >>>.lock-host", then the stat program will look for the file .lock-host
> >>>in the current directory.  You can see what the current directory is
> >>>by typing "pwd".  You can change the current directory using the "cd"
> >>>command.
> >>
> >>
> >>stat: cannot stat ‘/home/shraddha/git/sugar-build/.lock-host’: No
> >>such file or directory
> >>
> >>I'm searching why this is happening. Meanwhile if anything strikes you
> >>do let me know
> >
> >Since the open does fail, and yet the file does not exist, the problem
> >must be in creating the file.
> >
> >The most likely cause is owner or protection mask of the directory;
> >the directory in which the file is to be created, so please check:
> >
> >	stat /home/shraddha/git/sugar-build
> >
> >Example expected output;
> >
> > File: ‘/home/use/git/sugar-build’
> > Size: xxxxx           Blocks: xx         IO Block: xxxx   directory
> >Device: xxxh/xxxxd      Inode: xxxxxxxx    Links: xxx
> >Access: (0755/drwxr-xr-x)  Uid: ( 1000/   user)   Gid: ( 1000/   user)
> >Access: 2016-01-02 17:15:56.881528661 +1100
> >Modify: 2016-01-02 17:14:19.290923184 +1100
> >Change: 2016-01-02 17:14:19.290923184 +1100
> 
> 
> Okay so when I try stat I get the output. This is because I had
> cloned with root

Ouch.  Yes, that will cause problem.

> File: ‘/home/shraddha/git/sugar-build’
>   Size: 4096      	Blocks: 8          IO Block: 4096   directory
> Device: 805h/2053d	Inode: 5112265     Links: 5
> Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
> Access: 2016-01-02 12:22:17.908837058 +0530
> Modify: 2016-01-02 12:22:34.796837546 +0530
> Change: 2016-01-02 12:22:34.796837546 +0530
>  Birth: -
> 
> I deleted the file and again cloned without root which gives me-
> 
>   File: ‘/home/shraddha/git/sugar-build’
>   Size: 4096      	Blocks: 8          IO Block: 4096   directory
> Device: 805h/2053d	Inode: 5112265     Links: 5
> Access: (0775/drwxrwxr-x)  Uid: ( 1000/shraddha)   Gid: ( 1000/shraddha)
> Access: 2016-01-02 12:10:22.968816395 +0530
> Modify: 2016-01-02 12:13:37.952822030 +0530
> Change: 2016-01-02 12:13:37.952822030 +0530
> Birth: -

Good.

> 
> >
> >Also tell me your process uid and gid, by typing:
> >
> >	id
> >
> >Example expected output;
> >
> >uid=1000(user) gid=1000(user) groups=1000(user)
> 
> uid=1000(shraddha) gid=1000(shraddha) groups=1000(shraddha),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),131(sambashare)
> 
> This is the output without root.
> And when I run ./osbuild I get:
> 
> usage: osbuild [-h]
> {dist,build,karma,docs,check,shell,run,clean,pull,broot} ...
> osbuild: error: too few arguments

You can now try using osbuild according to the documentation.

I've made a pull request to fix the bug; so that next time someone
makes this mistake (clone as root) the error message will be better.

https://github.com/sugarlabs/sugar-build/pull/36

Thanks for answering questions.  I don't use sugar-build myself,
instead I use mock, rpmbuild, cowbuilder, debuild, autoconf, and make.

-- 
James Cameron
http://quozl.netrek.org/


More information about the Sugar-devel mailing list