Posts Tagged ‘osx’

Snow Leopard, 64bits, Ruby and MySQL

I recently started again wanting to play a little bit with the so acclaimed Ruby on Rails framework. Being on a Mac, I had not much to do to start working, with Ruby & RoR already installed with my Snow Leopard default OS X install (maybe because I’ve already installed the XCode Developer package, as well as the iPhone’s one… maybe you should check). So I was playing with my Ruby on Rails’ guide and I had already started building a project, having it displayed in my browser, so I knew the core of the install was up and ready.

Next step was to connect with MySQL. It proved not to be so simple as expected… Running rake db:migrate to check Ruby was well connected with MySQL lead to the following errors (both errors came repeatedly during my way to the solution, given below…):

  • uninitialized constant MysqlCompat::MysqlRes
  • dyld: lazy symbol binding failed: Symbol not found: _mysql_init
    Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/

After some research and tests following different articles on the net, I finally got with a working solution (however please notice that it applies to an Intel Mac with 64bits processor under Snow Leopard):

  • Install the latest x86_64 MySQL release (currently the mysql-5.1.53-osx10.6-x86_64). Several articles on the net will tell you the problems are due to the 64 bits version, you should install the 32 bits one, and so on. In my case, I tried both and it worked with the 64 bits one.
  • Make it work! Check the install documentation, connect with mysql, start the server… to be sure everything is working. A good thing would be to be able to connect to it with phpMyAdmin for example (which I did).
  • If you had already install the mysql gem (which you should have to need this page because you must have faced the previously mentioned issues…), uninstall it with sudo gem uninstall mysql.
  • The trick is then to reinstall it with the following command line: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config which ensures the gem is installed for the 64bits architecture, matching the MySQL one.

Then, you should not face the previous problem any more, maybe some access denials due to misconfiguration in your RoR’s project “database.yml” file or your MySQL configuration. But the Ruby/MySQL connection should be OK!

Categories: Mac OS X Tips Tags: , , , , ,

Make Wireshark work on OS X

You just have to make the BPF file of libcap readable with the following command (in your terminal):
sudo chown {your account name} /dev/bpf*

Original tip source

Categories: Mac OS X Tips Tags: , , ,

AFP (Apple File sharing Protocol) issues when sharing between same user

Here was my problem: I have 2 Macs, with one user account on each of them. Both user accounts share the same username (quite easier, isn’t it?). I use Mac B to connect to Mac A with my user’s login/password, I go through my files on Mac A, which I can read, but impossible to edit or create anything! Seems I’ve no write rights! Same problem in the other way! But no problem when connecting with Mac B to another user account on Mac A!

NB: the considered user accounts have administrator rights on both Mac, and all files have read/write permissions for this user.While I don’t think it is of any importance, I performed a migration of the user account from Mac A to Mac B with the “Migration Assistant” tool provided in MacOS X. My both Macs are under Snow Leopard 10.6.3, but this seems to be a common issues between numerous versions of OS X.

Googling a little a good hour, I found the explanation, and a solution. The reason is that, while the user accounts on Mac A and Mac B share the same username, they do not share the same UID (Unique ID, a number used by the system to identify a user account – it is generally hidden to the user, replaced by the username). This is due to the fact on Mac A, I created another user account before this one, so it took the 502 UID. On Mac B however, it was the first one so it took the 501…

Don’t ask me why, but this is the reason of all these write permissions problem, so now, how shall we address this issue? The solution is quite technical, and may be risky if you do not master what you’re doing, so please be prudent, and remember I shall not be taken responsible of any consequence of your acts! If advise you to do this only if you already know what the Terminal is, and how to use it. If not, ask a friend!

To fix this issue, you will indeed need to change your user’s UID manually. This requires terminal manipulation…

  1. First, you should check you really have the described problem (UID inconsistency). For this, you can execute the following command on both Macs: dscl . -read /Users/replace-with-your-username UniqueID. It should give you an answer of this form: UniqueID: 502. If answers are not the same for both Macs, you have this problem, and this is probably the cause of your file sharing issues.
  2. You now have to change your UID on one of the Macs to match with the one on the other. Be sure not to change to a UID already used by another user account in case you have multiple users on the Mac you wish to make the change on. For this, use the following command: sudo dscl . -change /Users/replace-with-your-username UniqueID replace-with-originalUID replace-with-targetUID. This will change from originalUID to targetUID.
  3. Finally, you need to update your whole user’s folder permissions to match your new UID. Since the terminal you’re logged in do not know you anymore (you changed your UID, remember?), you should open a new one (asked a password in my case), and use the following command to update your UID for all your files: sudo chown -R replace-with-targetUID /Users/romain/.
  4. Finally give your Mac a restart, it will help him not loosing track of you!

If you did this, I hope it worked for you as it did for me! You can give a eye to the following pages which I used to identify the issue and solution, if you want to be sure before doing it:

%d bloggers like this: