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

svim ignores configs after restart, and is unstartable after reinstall #21

Closed
chrisgrieser opened this issue Sep 10, 2022 · 2 comments
Closed

Comments

@chrisgrieser
Copy link

Hi, sorry to bother you once more 🙈

So the after everything with Alfred worked fine after updating to 1.0.9, I made changes to the svimrc and restarted svim to load those changes (brew services restart svim).

From then on, svim did not recognize any configs anymore – neither in the blacklist file, nor in the svimrc. (and I made sure I did not include any comments, like in #18). Restarting didn't help, but I did notice an svim still being listed as active process, so I killed that process, too, but that also didn't change anything.

So then I decided to reinstall svim and restarted my machine, but weirdly after that, svim refuses to launch at all. running as a foreground service (svim) only results gives this error message: Error: Could not create lock-file..

@FelixKratz
Copy link
Owner

FelixKratz commented Sep 10, 2022

To be honest I think the changes are not accepted because an instance of svim is still running and that one blocks all other instances from starting a second time.

As you can see here (svimrc)

SketchyVim/src/buffer.c

Lines 8 to 19 in 75d24df

void buffer_loadrc(struct buffer* buffer) {
char* home = getenv("HOME");
char buf[512];
snprintf(buf, sizeof(buf), "%s/%s", home, ".config/svim/svimrc");
char_u* file = (char_u*) read_file(buf);
if (file) {
vimExecute(file);
free(file);
}
vimExecute("set nocindent nosmartindent noautoindent");
}

and here (blacklist)
void event_tap_load_blacklist(struct event_tap* event_tap) {
event_tap->blacklist = NULL;
event_tap->blacklist_count = 0;
event_tap->front_app_ignored = true;
char* home = getenv("HOME");
char buf[512];
snprintf(buf, sizeof(buf), "%s/%s", home, ".config/svim/blacklist");
FILE *file = fopen(buf, "r");
if (!file) return;
char line[255];
while (fgets(line, 255, file)) {
uint32_t len = strlen(line);
if (line[len - 1] == '\n') line[len - 1] = '\0';
event_tap->blacklist = realloc(event_tap->blacklist,
sizeof(char**) * ++event_tap->blacklist_count);
event_tap->blacklist[event_tap->blacklist_count - 1] = string_copy(line);
}
fclose(file);
}

there is nothing magic happening there in terms of reading the config files.

Regarding the error you now get, it originates from here:

SketchyVim/src/main.m

Lines 9 to 23 in 75d24df

static void acquire_lockfile(void) {
int handle = open("/tmp/svim.lock", O_CREAT | O_WRONLY, 0600);
if (handle == -1) printf("Error: Could not create lock-file.\n"), exit(1);
struct flock lockfd = {
.l_start = 0,
.l_len = 0,
.l_pid = getpid(),
.l_type = F_WRLCK,
.l_whence = SEEK_SET
};
if (fcntl(handle, F_SETLK, &lockfd) == -1)
printf("Error: Could not acquire lock-file.\n"), exit(1);
}

and it means that the handle on the file /tmp/svim.lock could not be acquired:

open("/tmp/svim.lock", O_CREAT | O_WRONLY, 0600)

this could be an artifact of two users on the same machine both using svim. Then the lock file will be inaccessible for an unprivileged user.

You could try to delete that file by force

rm -rf /tmp/svim.lock

It could also be that there are too many open files on your system and creating a new fd is blocked by the system, but then you would notice other strange behavior very soon.

@chrisgrieser
Copy link
Author

You could try to delete that file by force
rm -rf /tmp/svim.lock

Thanks! that did the trick and also made svim load the configs properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants