組み込みProgrammerのチラシの裏

Create-rails-sample-on-sakura-internet

| Comments

さくらインターネット上でRuby on Railsを使用する続き。 portからインストールしようとしたけど挫折した話。

rails new

普通にrails newするとsqliteを使おうとしてエラーになる。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$ rails -v
Rails 4.2.5.1
$ rails new sample
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/<user>/local/rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/<user>/local/rbenv/versions/2.1.5/bin/ruby
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /home/<user>/local/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.11 for inspection.
Results logged to /home/<user>/local/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-freebsd-9/2.1.0-static/sqlite3-1.3.11/gem_make.out
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
         run  bundle exec spring binstub --all

さくらインターネットではmysqlがあるので、sqliteの代わりにmysqlを使うように変更する。

1
$ rails new sample --database=mysql

libexecinfoをインストール

1
2
3
4
5
6
7
8
9
10
11
12
$ mkdir -p ~/local/src/libexecinfo
$ cd ~/local/src/libexecinfo
$ wget http://pkg.freebsd.org/freebsd:11:x86:32/latest/All/libexecinfo-1.1_3.txz
$ tar xvzf libexecinfo-1.1_3.txz
x +COMPACT_MANIFEST
x +MANIFEST
tar: Removing leading '/' from member names
x usr/local/include/execinfo.h
x usr/local/lib/libexecinfo.a
x usr/local/lib/libexecinfo.so
x usr/local/lib/libexecinfo.so.1
x usr/local/share/doc/libexecinfo/README

ここでエラーになるが気にしない。

1
2
$ cp usr/local/include/* ~/local/include/
$ cp usr/local/lib/* ~/local/lib/

Node.jsをインストール

1
2
3
4
$ cd local/
$ mkdir -p work/ports/distfiles
$ mkdir -p var/db/portsnap
$ vi work/ports/portsnap.conf
~/local/work/ports/portsnap.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Default directory where compressed snapshots are stored.
WORKDIR=/home/<user name>/local/var/db/portsnap

# Default location of the ports tree (target for "update" and  "extract").
PORTSDIR=/home/<user name>/local/work/ports

# Server or server pool from which to fetch updates.  You can change
# this to point at a specific server if you want, but in most cases
# using a "nearby" server won't provide a measurable improvement in
# performance.
SERVERNAME=portsnap.FreeBSD.org

# Trusted keyprint.  Changing this is a Bad Idea unless you've received
# a PGP-signed email from <security-officer@FreeBSD.org> telling you to
# change it and explaining why.
KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330

# Example of ignoring parts of the ports tree.  If you know that you
# absolutely will not need certain parts of the tree, this will save
# some bandwidth and disk space.  See the manual page for more details.
#
# WARNING: Working with an incomplete ports tree is not supported and
# can cause problems due to missing dependencies.  If you have REFUSE
# directives and experience problems, remove them and update your tree
# before asking for help on the mailing lists.
#
REFUSE arabic chinese french german hebrew hungarian
REFUSE korean polish portuguese russian ukrainian vietnamese
REFUSE x11 x11-clocks x11-drivers x11-fm x11-fonts x11-servers x11-themes x11-toolkits x11-wm
REFUSE palm cad astro
1
2
3
4
$ portsnap -f ~/local/work/ports/portsnap.conf fetch extract update
$ mkdir ports
$ cd ports/
$ mkdir -p bin sbin etc lib tmp/dist tmp/work var/db/pkg var/db/ports var/run

.bashrcを編集

.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export PATH=${PATH}:${HOME}/local/ports/bin
export NODE_PATH=${HOME}/local/ports/bin/node
export NODE_MODULES=${HOME}/local/lib/node_modules
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/local/lib

export INSTALL_AS_USER=yes
export PREFIX=${HOME}/local/ports
export LOCALBASE=${HOME}/local/ports
export PKG_DBDIR=${LOCALBASE}/var/db/pkg
export PKG_TMPDIR=${LOCALBASE}/tmp/
export PORT_DBDIR=${LOCALBASE}/var/db/pkg
export DISTDIR=${LOCALBASE}/tmp/dist
export WRKDIRPREFIX=${LOCALBASE}/tmp/work
export PORTSDIR=${HOME}/local/work/ports
export PKGTOOLS_CONF=${LOCALBASE}/etc/pkgtools.conf
export DEPENDS_TARGET='install clean'

export X11BASE=${LOCALBASE}

export PKG_CONFIG_PATH="$HOME/local/ports/lib/pkgconfig:$HOME/local/ports/libdata/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/libdata/pkgconfig"

# Set user and group variables to ourself
export BINOWN=`whoami`
export BINGRP=`id -G -n ${BINOWN}`
export SHAREOWN=${BINOWN}
export SHAREGRP=${BINGRP}
export MANOWN=${BINOWN}
export MANGRP=${BINGRP}

# Make sure files are installed with correct default permissions
export BINMODE=744
export SHAREMODE=644
export MANMODE=644

# Make sure we don't really try to become root, but just execute everything as ourselves
export SU_CMD="sh -c"

# Make sure the systemdefault make.conf is not read
export __MAKE_CONF=${LOCALBASE}/etc/make.conf

# Keep our own version of ldconfig hints
export LDCONFIG="/sbin/ldconfig -i -f ${LOCALBASE}/var/run/ld-elf.so.hints"
export LD_LIBRARY_PATH=${LOCALBASE}/lib
export LD_RUN_PATH=${LOCALBASE}/lib

export PATH=${LOCALBASE}/bin:${LOCALBASE}/sbin:${PATH}
export MANPATH_MAP=${LOCALBASE}/bin:${LOCALBASE}/man

# Set application specific variables to make sure it doesn't pick up things from the main system
export APXS=${LOCALBASE}/sbin/apxs
export PERL=${LOCALBASE}/bin/perl
export PERL5=${PERL}
export SITE_PERL=${LOCALBASE}/lib/perl5/site_perl/5.8.8
export SITE_PERL5=${SITE_PERL}
export PERL_VERSION=5.8.8
export PERL_VER=${PERL_VERSION}

export SRCCONF=~/local/ports/etc/src.conf
1
$ cd ~/local/work/ports/www/node

一部ソースコードを修正。

deps/v8/src/base/platform/platform-posix.cc
1
2
3
4
5
6
7
8
9
10
11
12
--- deps/v8/src/base/platform/platform-posix.cc.default 2016-02-13 00:47:54.000000000 +0900
+++ deps/v8/src/base/platform/platform-posix.cc 2016-02-13 00:52:48.000000000 +0900
@@ -327,7 +327,8 @@
 #elif V8_OS_ANDROID
   return static_cast<int>(gettid());
 #else
-  return static_cast<int>(pthread_self());
+//  return static_cast<int>(pthread_self());
+  return reinterpret_cast<int64_t>(pthread_self());
 #endif
 }

deps/v8/src/base/platform/platform-freebsd.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- deps/v8/src/base/platform/platform-freebsd.cc.default       2016-02-13 00:45:50.000000000 +0900
+++ deps/v8/src/base/platform/platform-freebsd.cc       2016-02-13 00:47:14.000000000 +0900
@@ -122,10 +122,10 @@


 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
-  std::vector<SharedLibraryAddress> result;
+  std::vector<SharedLibraryAddress> address_result;
   static const int MAP_LENGTH = 1024;
   int fd = open("/proc/self/maps", O_RDONLY);
-  if (fd < 0) return result;
+  if (fd < 0) return address_result;
   while (true) {
     char addr_buffer[11];
     addr_buffer[0] = '0';
@@ -156,10 +156,10 @@
     // There may be no filename in this line.  Skip to next.
     if (start_of_path == NULL) continue;
     buffer[bytes_read] = 0;
-    result.push_back(SharedLibraryAddress(start_of_path, start, end));
+    address_result.push_back(SharedLibraryAddress(start_of_path, start, end));
   }
   close(fd);
-  return result;
+  return address_result;
 }


deps/v8/tools/gyp/v8.gyp
1
2
3
4
5
6
7
8
9
10
11
--- deps/v8/tools/gyp/v8.gyp.default    2016-02-13 00:59:24.000000000 +0900
+++ deps/v8/tools/gyp/v8.gyp    2016-02-13 01:04:51.000000000 +0900
@@ -1215,7 +1215,7 @@
         ['OS=="freebsd"', {
             'link_settings': {
               'libraries': [
-                '-L/usr/local/lib -lexecinfo',
+#                '-L/usr/local/lib -lexecinfo',
             ]},
             'sources': [
               '../../src/base/platform/platform-freebsd.cc',

perl5.18のビルドに失敗して先に進まない。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$ cd ~/local/work/ports/www/node
$ make install
===>   node-5.5.0 depends on executable: gmake - found
===>   node-5.5.0 depends on file: /home/<user>/local/ports/bin/python2.7 - found
===>   node-5.5.0 depends on executable: python2 - found
===>   node-5.5.0 depends on executable: gcc48 - not found
===>   gcc-4.8.5_2 depends on file: /home/<user>/local/ports/bin/as - not found
===>   binutils-2.25.1,1 depends on file: /home/<user>/local/ports/lib/libgmp.so - found
===>   binutils-2.25.1,1 depends on file: /home/<user>/local/ports/lib/libmpfr.so - found
===>   binutils-2.25.1,1 depends on executable: bison - not found
===>   bison-2.7.1,1 depends on package: m4>=1.4.16,1 - found
===>   bison-2.7.1,1 depends on executable: msgfmt - found
===>   bison-2.7.1,1 depends on file: /home/<user>/local/ports/bin/perl5.8.8 - not found
===>  Installing for perl5.18-5.18.4_17
===>   Registering installation for perl5.18-5.18.4_17 as automatic
pkg-static: lstat(/home/<user>/local/ports/tmp/work/home/<user>/local/work/ports/lang/perl5.18/work/stage/home/<user>/local/ports/lib/perl5/site_perl/auto/): No such file or directory
*** [fake-pkg] Error code 74

Stop in /home/<user>/local/work/ports/lang/perl5.18.
*** [install] Error code 1

Stop in /home/<user>/local/work/ports/lang/perl5.18.
*** [build-depends] Error code 1

Stop in /home/<user>/local/work/ports/devel/bison.
*** [install] Error code 1

Stop in /home/<user>/local/work/ports/devel/bison.
*** [build-depends] Error code 1

Stop in /home/<user>/local/work/ports/devel/binutils.
*** [install] Error code 1

Stop in /home/<user>/local/work/ports/devel/binutils.
*** [build-depends] Error code 1

Stop in /home/<user>/local/work/ports/lang/gcc.
*** [install] Error code 1

Stop in /home/<user>/local/work/ports/lang/gcc.
*** [build-depends] Error code 1

Stop in /home/<user>/local/work/ports/www/node.
*** [install] Error code 1

Stop in /home/<user>/local/work/ports/www/node.
*** [reinstall] Error code 1

Stop in /home/<user>/local/work/ports/www/node.

Comments