Tag: git

GitLab: Your changes could not be commited, because the file has been changed

Not long ago I've migrated last of my SVN-managed projects into Git with GitLab (finally!). Everything was OK, until this message occurred, when I tried to do an web-based repository file update:

Your changes could not be commited, because the file has been changed

After googling I've executed following command (because I didn't create satellites earlier):

sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production

Unfortunately this didn't solve my problem (although I'm pretty sure, that either way this was required). I've decided to check GitLab logs, but unluckily nothing suspicious was there. I suddenly remembered, that by default all my Rails/Rack Passenger applications are executed using www-data user. This was a good guess. I've added a user declaration in Apache vhost configuration file:

PassengerUser git

and after that I've finally started to get some new things in application log:

Errno::EACCES (Permission denied - /home/git/gitlab/tmp/satellite_15.lock):
  lib/gitlab/satellite/satellite.rb:57:in `initialize'
  lib/gitlab/satellite/satellite.rb:57:in `open'
  lib/gitlab/satellite/satellite.rb:57:in `lock'
  lib/gitlab/satellite/action.rb:23:in `block in in_locked_and_timed_satellite'
  lib/gitlab/satellite/action.rb:22:in `in_locked_and_timed_satellite'
  lib/gitlab/satellite/edit_file_action.rb:22:in `commit!'
  app/controllers/edit_tree_controller.rb:18:in `update'

All my satellite locks were created by www-data user with different set of privileges, so git user was not able to use them. After I removed all the locks and restarted both GitLab and Apache server, everything started to work just fine:

sudo rm /home/gitlab/tmp/satellite_*
/etc/init.d/apache2 restart
/etc/init.d/gitlab restart

Rails3 + Paperclip + dużo nowych błędów

Dzisiaj przyszło mi się zmierzyć z kolejnymi problemami związanymi z Paperclipem. O ile na 1.8.7 i R3 działał, o tyle na 1.9.2 - przestał. Nie wiem czym to idzie, ale czuję że ten plugin żyje czasem swoim własnym życiem.

Sypie między innymi takimi błędami jak:

  • Paperclip::NotIdentifiedByImageMagickError
  • can't convert nil into Integer
  • is not recognized by the 'identify' command

Trzeba coś było z tym zrobić. Po kilku godzinach poszukiwań i eksperymentów udało się! Paperclip wkońcu działa na Railsach 3.0.0 i Rubym 1.9.2-p0. Jak powtórzyć mój sukces? Pierwszą rzeczą jaką musimy zrobić, jest ściągnięcie wersji 2.3.1. Robimy to klonując repozytorium z gita:

git clone git://github.com/thoughtbot/paperclip.git

a następnie zmieniamy tag:

cd paperclip
git checkout v2.3.1

Jest to ostatnia wersja korzystająca ze "starego" procesora. Paradoksalnie, to nowe powinny działać, jednak w moim wypadku stare okazuje się dużo lepsze. Nowsze wersje także działały ale "po części". Przede wszystkim, niezgodne i18n w moim wypadku. Musiałbym je troszkę poprawiać aby internacjonalizacja Paperclipa działała. Po drugie jeśli ładowaliśmy nieprawidłowy format pliku, to owszem, wyłapywało błąd, jednak zgłaszało także błędy identify.

Wróćmy jednak do właściwego tematu. Co zrobić aby Paperclip zaczął działać? Mając już cały plugin w vendor/plugins/ otwieramy plik lib/paperclip/attachment.rb i zmieniamy następującą linijkę (okolice 45-46 linijki):

# lib/paperclip/attachment.rb
instance.run_callbacks(which, @queued_for_write) {|result, obj| false } # commented to make it work with rails 3 & ruby 1.9 {|result, obj| result == false }

na:

instance.run_callbacks(which, @queued_for_write) # commented to make it work with rails 3 & ruby 1.9 {|result, obj| result == false }

Następnie bierzemy się za plik lib/paperclip/processor.rb i zmieniamy:

# lib/paperclip/processor.rb
sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n, extension)

na:

sprintf("%s,%d,%s%s", File.basename(basename, extension), $$, n, extension)

Te linijki wyglądają PRAWIE identycznie, więc nie radzę się pomylić ;)

Od teraz mamy działającego ładnie i bezproblemowo Paperclipa.

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑